#[non_exhaustive]pub struct PageInfo {
pub has_next: bool,
pub has_prev: bool,
pub next_cursor: Option<String>,
pub prev_cursor: Option<String>,
pub total: Option<u64>,
}Expand description
Page information for paginated responses.
§Example
let page_info = PageInfo::new(20, 20)
.with_next_cursor(Some("abc123".to_string()))
.with_prev_cursor(Some("xyz789".to_string()))
.with_total(100);
assert!(page_info.has_next);
assert!(page_info.has_prev);
assert_eq!(page_info.total, Some(100));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.has_next: boolWhether there are more items after this page.
has_prev: boolWhether there are items before this page.
next_cursor: Option<String>Cursor to fetch the next page.
prev_cursor: Option<String>Cursor to fetch the previous page.
total: Option<u64>Total count (if available).
Implementations§
Source§impl PageInfo
impl PageInfo
Sourcepub const fn new(count: usize, limit: usize) -> Self
pub const fn new(count: usize, limit: usize) -> Self
Create page info based on returned count vs requested limit.
If count >= limit, assumes there are more items.
Sourcepub const fn with_has_prev(self, has_prev: bool) -> Self
pub const fn with_has_prev(self, has_prev: bool) -> Self
Set whether there are previous items.
Sourcepub fn with_next_cursor(self, cursor: Option<String>) -> Self
pub fn with_next_cursor(self, cursor: Option<String>) -> Self
Set the next cursor.
Sourcepub fn with_prev_cursor(self, cursor: Option<String>) -> Self
pub fn with_prev_cursor(self, cursor: Option<String>) -> Self
Set the previous cursor.
Sourcepub const fn with_total(self, total: u64) -> Self
pub const fn with_total(self, total: u64) -> Self
Set the total count.
Trait Implementations§
impl Eq for PageInfo
impl StructuralPartialEq for PageInfo
Auto Trait Implementations§
impl Freeze for PageInfo
impl RefUnwindSafe for PageInfo
impl Send for PageInfo
impl Sync for PageInfo
impl Unpin for PageInfo
impl UnwindSafe for PageInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more