//! Shared pagination envelope for list endpoints. //! //! `total` is `Option` and is always serialised — `null` when the //! handler hasn't computed it yet, a number once it has. The shape is fixed //! across `/mangas`, `/chapters`, `/bookmarks`, etc. so consumers can //! handle pagination uniformly. use serde::Serialize; #[derive(Debug, Serialize)] pub struct PageInfo { pub limit: i64, pub offset: i64, pub total: Option, } #[derive(Debug, Serialize)] pub struct PagedResponse { pub items: Vec, pub page: PageInfo, } impl PagedResponse { pub fn new(items: Vec, limit: i64, offset: i64) -> Self { Self { items, page: PageInfo { limit, offset, total: None }, } } pub fn with_total(items: Vec, limit: i64, offset: i64, total: i64) -> Self { Self { items, page: PageInfo { limit, offset, total: Some(total) }, } } }