pub struct Paginator<T> {
pub items: Vec<T>,
pub total: i64,
pub per_page: u64,
pub current_page: u64,
pub last_page: u64,
}Expand description
Page-aware paginator. Produced by QueryBuilder::paginate(per_page, page, pool).
Fields§
§items: Vec<T>The rows on the current page.
total: i64Total row count across all pages (a COUNT(*) against the same query).
per_page: u64Rows per page.
current_page: u641-indexed current page.
last_page: u641-indexed last page (computed from total + per_page).
Implementations§
Source§impl<T> Paginator<T>
impl<T> Paginator<T>
Sourcepub fn new(
items: Vec<T>,
total: i64,
per_page: u64,
current_page: u64,
) -> Paginator<T>
pub fn new( items: Vec<T>, total: i64, per_page: u64, current_page: u64, ) -> Paginator<T>
Build a paginator from a fetched page + the global count.
pub fn has_more_pages(&self) -> bool
pub fn has_previous_pages(&self) -> bool
pub fn next_page(&self) -> Option<u64>
pub fn previous_page(&self) -> Option<u64>
Sourcepub fn from(&self) -> Option<u64>
pub fn from(&self) -> Option<u64>
from and to are 1-indexed row positions within the full result set.
pub fn to(&self) -> Option<u64>
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl<T> Serialize for Paginator<T>where
T: Serialize,
impl<T> Serialize for Paginator<T>where
T: Serialize,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl<T> Freeze for Paginator<T>
impl<T> RefUnwindSafe for Paginator<T>where
T: RefUnwindSafe,
impl<T> Send for Paginator<T>where
T: Send,
impl<T> Sync for Paginator<T>where
T: Sync,
impl<T> Unpin for Paginator<T>where
T: Unpin,
impl<T> UnsafeUnpin for Paginator<T>
impl<T> UnwindSafe for Paginator<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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