Struct rdb_pagination_core::PaginationOptions
source · pub struct PaginationOptions<T: OrderByOptions = ()> {
pub page: usize,
pub items_per_page: usize,
pub order_by: T,
}Expand description
Struct representing pagination options.
§Examples
let options = PaginationOptions::new().page(1).items_per_page(20);Fields§
§page: usizePage number.
- If the value is
0, it will default to1. - If the value exceeds the maximum page number, it will be considered as the maximum page number.
Default: 1.
items_per_page: usizeNumber of items per page.
- If the value is
0, it means query all items in a single page.
Default: 0.
order_by: TOrdering options which has to implement the OrderByOptions trait.
Default: ().
Implementations§
source§impl<T: OrderByOptions> PaginationOptions<T>
impl<T: OrderByOptions> PaginationOptions<T>
sourcepub const fn page(self, page: usize) -> Self
pub const fn page(self, page: usize) -> Self
Set the page number.
- If the value is
0, it will be considered as1. - If the value exceeds the maximum page number, it will be considered as the maximum page number.
sourcepub const fn items_per_page(self, items_per_page: usize) -> Self
pub const fn items_per_page(self, items_per_page: usize) -> Self
Set the number of items per page.
- If the value is
0, it means query all items in a single page.
source§impl<T: OrderByOptions> PaginationOptions<T>
impl<T: OrderByOptions> PaginationOptions<T>
sourcepub fn to_mysql_limit_offset<'a>(&self, s: &'a mut String) -> &'a str
pub fn to_mysql_limit_offset<'a>(&self, s: &'a mut String) -> &'a str
Generate a LIMIT with OFFSET clause for MySQL.
If limit() is Some(n),
LIMIT <limit()> [OFFSET <offset()>]
If offset() is not zero,
[LIMIT <limit()>] OFFSET <offset()>
Trait Implementations§
source§impl<T: Clone + OrderByOptions> Clone for PaginationOptions<T>
impl<T: Clone + OrderByOptions> Clone for PaginationOptions<T>
source§fn clone(&self) -> PaginationOptions<T>
fn clone(&self) -> PaginationOptions<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<T: Debug + OrderByOptions> Debug for PaginationOptions<T>
impl<T: Debug + OrderByOptions> Debug for PaginationOptions<T>
source§impl<T: OrderByOptions> Default for PaginationOptions<T>
impl<T: OrderByOptions> Default for PaginationOptions<T>
source§impl<'de, T: OrderByOptions + Deserialize<'de>> Deserialize<'de> for PaginationOptions<T>
impl<'de, T: OrderByOptions + Deserialize<'de>> Deserialize<'de> for PaginationOptions<T>
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<T: OrderByOptions + Serialize> Serialize for PaginationOptions<T>
impl<T: OrderByOptions + Serialize> Serialize for PaginationOptions<T>
Auto Trait Implementations§
impl<T> Freeze for PaginationOptions<T>
impl<T> RefUnwindSafe for PaginationOptions<T>where
T: Default + RefUnwindSafe,
impl<T> Send for PaginationOptions<T>
impl<T> Sync for PaginationOptions<T>
impl<T> Unpin for PaginationOptions<T>
impl<T> UnwindSafe for PaginationOptions<T>where
T: Default + 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