pub struct Pagination {
pub page: usize,
pub per_page: usize,
pub reverse: bool,
}Expand description
Simple struct that is used to add pagination to some endpoint like: /endpoint?page=1&per_page=10
The page numbers start at “1”, so they match what you would display in a frontend.
The default implementation returns you page=1 and per_page=1000.
Fields§
§page: usize§per_page: usize§reverse: boolImplementations§
Source§impl Pagination
impl Pagination
Sourcepub fn from_query(query: Option<&str>) -> Option<Pagination>
pub fn from_query(query: Option<&str>) -> Option<Pagination>
Extracts a pagination from some query string (if any).
The query can contain other elements aswell and there is no necessity for the pieces
page and per_page to be two consecutive elements in the query.
As long as there is a page={} element and a per_page={} element,
this function will successfully parse and return the Pagination struct.
Trait Implementations§
Source§impl Clone for Pagination
impl Clone for Pagination
Source§fn clone(&self) -> Pagination
fn clone(&self) -> Pagination
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for Pagination
impl Default for Pagination
Source§impl From<Pagination> for Range<usize>
impl From<Pagination> for Range<usize>
Source§fn from(value: Pagination) -> Self
fn from(value: Pagination) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Pagination
impl RefUnwindSafe for Pagination
impl Send for Pagination
impl Sync for Pagination
impl Unpin for Pagination
impl UnsafeUnpin for Pagination
impl UnwindSafe for Pagination
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