pub struct Pager { /* private fields */ }Expand description
A single page request resolved from an optional cursor and a page size.
Paginated tools follow a fetch-one-extra pattern: query size + 1 rows,
then call Self::paginate to trim the extra row and emit a next cursor
when present. Construct with Self::new; read Self::offset /
Self::limit when building the SQL statement.
Implementations§
Source§impl Pager
impl Pager
Sourcepub fn new(cursor: Option<Cursor>, size: u16) -> Self
pub fn new(cursor: Option<Cursor>, size: u16) -> Self
Builds a page request from an optional cursor and the configured page size.
Sourcepub fn offset(&self) -> i64
pub fn offset(&self) -> i64
Row offset at which this page starts.
Returned as i64 so the value is directly bindable to sqlx
LIMIT/OFFSET placeholders across every backend. Saturates at
i64::MAX for cursor offsets that exceed the signed range.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pager
impl RefUnwindSafe for Pager
impl Send for Pager
impl Sync for Pager
impl Unpin for Pager
impl UnsafeUnpin for Pager
impl UnwindSafe for Pager
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