pub struct Paginator<'db, C, M> { /* private fields */ }Expand description
Page-by-page access to a query.
Implementations§
Source§impl<C: ConnectionTrait, M: FromQueryResult> Paginator<'_, C, M>
impl<C: ConnectionTrait, M: FromQueryResult> Paginator<'_, C, M>
Sourcepub async fn fetch_page(&self, page: u64) -> Result<Vec<M>>
pub async fn fetch_page(&self, page: u64) -> Result<Vec<M>>
Fetches the rows of page page, counted from zero.
§Errors
Returns DbErr::Driver when the query fails or a row cannot be decoded.
Sourcepub async fn num_items(&self) -> Result<u64>
pub async fn num_items(&self) -> Result<u64>
The total number of rows.
§Errors
Returns DbErr::RecordNotFound when the count query returns no
row; DbErr::Driver when the query fails.
Sourcepub async fn num_items_and_pages(&self) -> Result<(u64, u64)>
pub async fn num_items_and_pages(&self) -> Result<(u64, u64)>
Sourcepub async fn for_each_page(&self, f: impl FnMut(Vec<M>) -> bool) -> Result<()>
pub async fn for_each_page(&self, f: impl FnMut(Vec<M>) -> bool) -> Result<()>
Fetches every page in turn, calling f with each one, until a page
comes back short or f returns false.
§Errors
Returns the errors of fetch_page.
Trait Implementations§
Auto Trait Implementations§
impl<'db, C, M> Freeze for Paginator<'db, C, M>
impl<'db, C, M> RefUnwindSafe for Paginator<'db, C, M>
impl<'db, C, M> Send for Paginator<'db, C, M>
impl<'db, C, M> Sync for Paginator<'db, C, M>
impl<'db, C, M> Unpin for Paginator<'db, C, M>
impl<'db, C, M> UnsafeUnpin for Paginator<'db, C, M>
impl<'db, C, M> UnwindSafe for Paginator<'db, C, M>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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