pub struct PaginatorResponseMeta {
pub page: u32,
pub per_page: u32,
pub total: Option<u32>,
pub total_pages: Option<u32>,
pub has_next: bool,
pub has_prev: bool,
pub next_cursor: Option<String>,
pub prev_cursor: Option<String>,
}Fields§
§page: u32§per_page: u32§total: Option<u32>§total_pages: Option<u32>§has_next: bool§has_prev: bool§next_cursor: Option<String>§prev_cursor: Option<String>Implementations§
Source§impl PaginatorResponseMeta
impl PaginatorResponseMeta
pub fn new(page: u32, per_page: u32, total: u32) -> Self
pub fn new_without_total(page: u32, per_page: u32, has_next: bool) -> Self
pub fn new_with_cursors( page: u32, per_page: u32, total: Option<u32>, has_next: bool, next_cursor: Option<String>, prev_cursor: Option<String>, ) -> Self
Sourcepub fn from_cursor_page<T: Serialize>(
rows: &mut Vec<T>,
params: &PaginationParams,
plan: &KeysetPlan<'_>,
total: Option<u32>,
) -> Self
pub fn from_cursor_page<T: Serialize>( rows: &mut Vec<T>, params: &PaginationParams, plan: &KeysetPlan<'_>, total: Option<u32>, ) -> Self
Build the metadata for a keyset page and normalize its rows.
rows must be what the cursor query returned with LIMIT per_page + 1, in
query order (see KeysetPlan::query_sort). The overflow row, if any, is
dropped and a Before page is flipped back into the caller’s sort order.
has_next/has_prev describe the side of the page that was probed: an
After page knows whether more rows follow and always reports rows behind
it, and a Before page the reverse. next_cursor/prev_cursor are derived
from the last and first row and are only set when that side has more rows,
the page is not empty, and the cursor field can be read from the serialized
row (see Cursor::value_from_row).
Trait Implementations§
Source§impl Debug for PaginatorResponseMeta
impl Debug for PaginatorResponseMeta
Source§impl<'de> Deserialize<'de> for PaginatorResponseMeta
impl<'de> Deserialize<'de> for PaginatorResponseMeta
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for PaginatorResponseMeta
impl RefUnwindSafe for PaginatorResponseMeta
impl Send for PaginatorResponseMeta
impl Sync for PaginatorResponseMeta
impl Unpin for PaginatorResponseMeta
impl UnsafeUnpin for PaginatorResponseMeta
impl UnwindSafe for PaginatorResponseMeta
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