Skip to main content

PaginatorResponseMeta

Struct PaginatorResponseMeta 

Source
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

Source

pub fn new(page: u32, per_page: u32, total: u32) -> Self

Source

pub fn new_without_total(page: u32, per_page: u32, has_next: bool) -> Self

Source

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

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PaginatorResponseMeta

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for PaginatorResponseMeta

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.