pub struct PageRequest { /* private fields */ }Expand description
Page request metadata.
Implementations§
Source§impl PageRequest
impl PageRequest
Sourcepub const fn new(page: usize, per_page: usize) -> PageRequest
pub const fn new(page: usize, per_page: usize) -> PageRequest
Creates a page request. Values are stored as provided for caller-defined paging schemes.
Examples found in repository?
examples/basic_usage.rs (line 13)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let database = DatabaseName::new("app")?;
8 let schema = SchemaName::new("public")?;
9 let table = TableName::new("users")?;
10 let column = ColumnName::new("id")?;
11
12 let primary_key = PrimaryKey::new(table.clone(), column.clone());
13 let page = PageRequest::new(1, 50);
14 let isolation = TransactionIsolation::Serializable;
15
16 assert_eq!(database.as_str(), "app");
17 assert_eq!(schema.as_str(), "public");
18 assert_eq!(primary_key.table(), &table);
19 assert_eq!(primary_key.column(), &column);
20 assert_eq!(page.per_page(), 50);
21 assert_eq!(SortDirection::Ascending.as_str(), "ascending");
22 assert_eq!(isolation.as_str(), "serializable");
23
24 Ok(())
25}Sourcepub const fn per_page(self) -> usize
pub const fn per_page(self) -> usize
Returns the page-size value.
Examples found in repository?
examples/basic_usage.rs (line 20)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let database = DatabaseName::new("app")?;
8 let schema = SchemaName::new("public")?;
9 let table = TableName::new("users")?;
10 let column = ColumnName::new("id")?;
11
12 let primary_key = PrimaryKey::new(table.clone(), column.clone());
13 let page = PageRequest::new(1, 50);
14 let isolation = TransactionIsolation::Serializable;
15
16 assert_eq!(database.as_str(), "app");
17 assert_eq!(schema.as_str(), "public");
18 assert_eq!(primary_key.table(), &table);
19 assert_eq!(primary_key.column(), &column);
20 assert_eq!(page.per_page(), 50);
21 assert_eq!(SortDirection::Ascending.as_str(), "ascending");
22 assert_eq!(isolation.as_str(), "serializable");
23
24 Ok(())
25}Trait Implementations§
Source§impl Clone for PageRequest
impl Clone for PageRequest
Source§fn clone(&self) -> PageRequest
fn clone(&self) -> PageRequest
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 Debug for PageRequest
impl Debug for PageRequest
Source§impl Hash for PageRequest
impl Hash for PageRequest
Source§impl Ord for PageRequest
impl Ord for PageRequest
Source§fn cmp(&self, other: &PageRequest) -> Ordering
fn cmp(&self, other: &PageRequest) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for PageRequest
impl PartialEq for PageRequest
Source§fn eq(&self, other: &PageRequest) -> bool
fn eq(&self, other: &PageRequest) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for PageRequest
impl PartialOrd for PageRequest
impl Copy for PageRequest
impl Eq for PageRequest
impl StructuralPartialEq for PageRequest
Auto Trait Implementations§
impl Freeze for PageRequest
impl RefUnwindSafe for PageRequest
impl Send for PageRequest
impl Sync for PageRequest
impl Unpin for PageRequest
impl UnsafeUnpin for PageRequest
impl UnwindSafe for PageRequest
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