18 lines
347 B
Rust
18 lines
347 B
Rust
use serde::Serialize;
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct Paged<T: Serialize> {
|
|
pub items: Vec<T>,
|
|
pub total: i64,
|
|
pub page: i64,
|
|
pub per_page: i64,
|
|
}
|
|
|
|
pub fn clamp_page(page: Option<i64>) -> i64 {
|
|
page.unwrap_or(1).max(1)
|
|
}
|
|
|
|
pub fn clamp_per_page(per_page: Option<i64>) -> i64 {
|
|
per_page.unwrap_or(20).clamp(1, 100)
|
|
}
|