pub struct Pagination {
pub page: u32,
pub per_page: u32,
pub total: Option<u64>,
pub total_pages: Option<u32>,
}
Expand description
Pagination parameters for queries
Provides offset-based pagination with helpful utility methods for calculating offsets, page numbers, and navigation state.
§Examples
use libsql_orm::Pagination;
let mut pagination = Pagination::new(2, 10); // Page 2, 10 items per page
pagination.set_total(45); // 45 total items
assert_eq!(pagination.offset(), 10); // Skip first 10 items
assert_eq!(pagination.limit(), 10); // Take 10 items
assert_eq!(pagination.total_pages, Some(5)); // 5 total pages
assert!(pagination.has_prev()); // Has previous page
assert!(pagination.has_next()); // Has next page
Fields§
§page: u32
Page number (1-based)
per_page: u32
Number of items per page
total: Option<u64>
Total number of items (set after query execution)
total_pages: Option<u32>
Total number of pages (calculated)
Implementations§
Source§impl Pagination
impl Pagination
Sourcepub fn start_item(&self) -> u32
pub fn start_item(&self) -> u32
Get the start item number for the current page
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 · 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 Pagination
impl Debug for Pagination
Source§impl Default for Pagination
impl Default for Pagination
Source§impl<'de> Deserialize<'de> for Pagination
impl<'de> Deserialize<'de> for Pagination
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
Auto Trait Implementations§
impl Freeze for Pagination
impl RefUnwindSafe for Pagination
impl Send for Pagination
impl Sync for Pagination
impl Unpin 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