Skip to main content

Pager

Struct Pager 

Source
pub struct Pager<P: PagedResponse, E> { /* private fields */ }
Expand description

Fetches pages and retains unused items between bounded collections.

Implementations§

Source§

impl<P: PagedResponse, E> Pager<P, E>

Source

pub fn new<F, Fut>(cursor: Option<P::Cursor>, fetch: F) -> Self
where F: FnMut(Option<P::Cursor>) -> Fut + Send + 'static, Fut: Future<Output = Result<P, E>> + Send + 'static,

Creates a pager beginning at cursor.

Source

pub async fn next(&mut self) -> Option<Result<P, E>>

Returns the next page, or None after exhaustion.

Source

pub async fn collect_up_to( &mut self, max_items: usize, ) -> Result<Vec<P::Item>, E>

Returns at most max_items items.

Auto Trait Implementations§

§

impl<P, E> !RefUnwindSafe for Pager<P, E>

§

impl<P, E> !Sync for Pager<P, E>

§

impl<P, E> !UnwindSafe for Pager<P, E>

§

impl<P, E> Freeze for Pager<P, E>
where Box<dyn FnMut(Option<<P as PagedResponse>::Cursor>) -> Pin<Box<dyn Future<Output = Result<P, E>> + Send>> + Send>: Freeze, PagerState<<P as PagedResponse>::Cursor>: Freeze, Option<P>: Freeze,

§

impl<P, E> Send for Pager<P, E>
where Box<dyn FnMut(Option<<P as PagedResponse>::Cursor>) -> Pin<Box<dyn Future<Output = Result<P, E>> + Send>> + Send>: Send, PagerState<<P as PagedResponse>::Cursor>: Send, Option<P>: Send,

§

impl<P, E> Unpin for Pager<P, E>
where Box<dyn FnMut(Option<<P as PagedResponse>::Cursor>) -> Pin<Box<dyn Future<Output = Result<P, E>> + Send>> + Send>: Unpin, PagerState<<P as PagedResponse>::Cursor>: Unpin, Option<P>: Unpin,

§

impl<P, E> UnsafeUnpin for Pager<P, E>
where Box<dyn FnMut(Option<<P as PagedResponse>::Cursor>) -> Pin<Box<dyn Future<Output = Result<P, E>> + Send>> + Send>: UnsafeUnpin, PagerState<<P as PagedResponse>::Cursor>: UnsafeUnpin, Option<P>: UnsafeUnpin,

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> ErasedDestructor for T
where T: 'static,

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> 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.