cat_gateway/service/common/objects/generic/
pagination.rs1use poem_openapi::{types::Example, Object};
4
5use crate::service::common;
6
7#[allow(dead_code)]
9pub(crate) const CURRENT_PAGE_DESCRIPTION: &str =
10 "The Page of results is being returned, and the Limit of results.
11The data returned is constrained by this limit.
12The limit applies to the total number of records returned.
13*Note: The Limit may not be exactly as requested, if it was constrained by the response.
14The caller must read this record to ensure the correct data requested was returned.*";
15
16#[derive(Object)]
17#[oai(example = true)]
18pub(crate) struct CurrentPage {
20 #[allow(clippy::missing_docs_in_private_items)] pub page: common::types::generic::query::pagination::Page,
22 #[allow(clippy::missing_docs_in_private_items)] pub limit: common::types::generic::query::pagination::Limit,
24 #[allow(clippy::missing_docs_in_private_items)] pub remaining: common::types::generic::query::pagination::Remaining,
26}
27
28impl Example for CurrentPage {
29 fn example() -> Self {
30 Self {
31 page: common::types::generic::query::pagination::Page::example(),
32 limit: common::types::generic::query::pagination::Limit::example(),
33 remaining: common::types::generic::query::pagination::Remaining::example(),
34 }
35 }
36}
37
38impl CurrentPage {
39 #[allow(dead_code)]
46 fn new(page: u32, limit: u32, remaining: u32) -> anyhow::Result<Self> {
47 Ok(Self {
48 page: page.try_into()?,
49 limit: limit.try_into()?,
50 remaining: remaining.try_into()?,
51 })
52 }
53}