Skip to main content

PaginatedQueryRet

Struct PaginatedQueryRet 

Source
pub struct PaginatedQueryRet<T, C> {
    pub has_next_page: bool,
    pub end_cursor: Option<C>,
    /* private fields */
}
Expand description

Return type for paginated queries containing entities and pagination metadata

PaginatedQueryRet contains the fetched entities and utilities for continuing pagination. Returned by the EsRepo functions like list_by, list_for and list_for_filters. Used with PaginatedQueryArgs to perform consistent and efficient pagination

§Examples

let mut query = PaginatedQueryArgs { first: 10, after: None };
let mut all_users = Vec::new();

loop {
    let result = users.list_by_id(query, ListDirection::Ascending).await?;
    let (chunk, next) = result.into_parts();
    all_users.extend(chunk);

    match next {
        Some(next_query) => query = next_query,
        None => break,
    }
}

Fields§

§has_next_page: bool

bool for indicating if the list has been exhausted or more entities can be fetched

§end_cursor: Option<C>

cursor on the last entity fetched to continue paginated queries.

Implementations§

Source§

impl<T, C> PaginatedQueryRet<T, C>

Source

pub fn new( entities: Vec<T>, has_next_page: bool, end_cursor: Option<C>, requested_size: usize, ) -> Self

requested_size must be the first that produced this page, not entities.len().

Source

pub fn requested_size(&self) -> usize

Source

pub fn entities(&self) -> &[T]

Source

pub fn into_parts(self) -> (Vec<T>, Option<PaginatedQueryArgs<C>>)
where C: Debug,

Source

pub fn into_next_query(self) -> Option<PaginatedQueryArgs<C>>
where C: Debug,

Source

pub fn map_end_cursor<C2>( self, f: impl FnOnce(C) -> C2, ) -> PaginatedQueryRet<T, C2>

Source

pub fn map_entities<T2>( self, f: impl FnMut(T) -> T2, ) -> PaginatedQueryRet<T2, C>

Source

pub fn try_map_entities<T2, E>( self, f: impl FnMut(T) -> Result<T2, E>, ) -> Result<PaginatedQueryRet<T2, C>, E>

Auto Trait Implementations§

§

impl<T, C> Freeze for PaginatedQueryRet<T, C>
where Vec<T>: Freeze, Option<C>: Freeze,

§

impl<T, C> RefUnwindSafe for PaginatedQueryRet<T, C>

§

impl<T, C> Send for PaginatedQueryRet<T, C>
where Vec<T>: Send, Option<C>: Send,

§

impl<T, C> Sync for PaginatedQueryRet<T, C>
where Vec<T>: Sync, Option<C>: Sync,

§

impl<T, C> Unpin for PaginatedQueryRet<T, C>
where Vec<T>: Unpin, Option<C>: Unpin,

§

impl<T, C> UnsafeUnpin for PaginatedQueryRet<T, C>

§

impl<T, C> UnwindSafe for PaginatedQueryRet<T, C>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more