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()>Source§impl<T: OrderByOptions> PaginationOptions<T>
impl<T: OrderByOptions> PaginationOptions<T>
Sourcepub fn to_sqlite_limit_offset<'a>(&self, s: &'a mut String) -> &'a str
pub fn to_sqlite_limit_offset<'a>(&self, s: &'a mut String) -> &'a str
Generate a LIMIT with OFFSET clause for SQLite.
If limit() is Some(n),
LIMIT <limit()> [OFFSET <offset()>]If offset() is not zero,
[LIMIT <limit()>] OFFSET <offset()>Source§impl<T: OrderByOptions> PaginationOptions<T>
impl<T: OrderByOptions> PaginationOptions<T>
Sourcepub fn to_mssql_limit_offset<'a>(&self, s: &'a mut String) -> &'a str
pub fn to_mssql_limit_offset<'a>(&self, s: &'a mut String) -> &'a str
Generate a OFFSET with FETCH clause for Microsoft SQL Server.
If limit() is Some(n) or offset() is not zero,
OFFSET <offset()> ROWS [FETCH NEXT <limit()> ROWS ONLY]Source§impl<T: OrderByOptions> PaginationOptions<T>
impl<T: OrderByOptions> PaginationOptions<T>
Sourcepub fn to_mssql2008_limit_offset<'a>(
&self,
row_number_column_name: impl AsRef<str>,
s: &'a mut String,
) -> &'a str
pub fn to_mssql2008_limit_offset<'a>( &self, row_number_column_name: impl AsRef<str>, s: &'a mut String, ) -> &'a str
Generate a WHERE clause for Microsoft SQL Server 2008 and earlier (used for check the row number).
If limit() is Some(n),
WHERE [<row_number_column_name>] <= <limit()>If offset() is not zero,
WHERE [<row_number_column_name>] > <offset()>If both above are true,
WHERE [<row_number_column_name>] BETWEEN (<offset() + 1>) AND <offset() + limit()>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 duplicate 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>where
T: Freeze,
impl<T> RefUnwindSafe for PaginationOptions<T>where
T: RefUnwindSafe,
impl<T> Send for PaginationOptions<T>where
T: Send,
impl<T> Sync for PaginationOptions<T>where
T: Sync,
impl<T> Unpin for PaginationOptions<T>where
T: Unpin,
impl<T> UnwindSafe for PaginationOptions<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