17 lines
567 B
Rust
17 lines
567 B
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct SearchResult<T> {
|
|
pub results: Vec<T>,
|
|
pub current_page: i32,
|
|
pub total_pages: i32,
|
|
}
|
|
|
|
/// This constant should be used everywhere so that it can easily changed.
|
|
pub const ROWS_PER_PAGE: i32 = 200;
|
|
|
|
/// This gets an i32 from an Option<&str>. It is very fail safe of any bad value, where it will return 1 instead of an error.
|
|
pub fn get_page_number_as_i32_from_str(page_as_str: Option<&str>) -> i32 {
|
|
str::parse(page_as_str.unwrap_or("1")).unwrap_or(1)
|
|
}
|