pub struct CursorPaginate {
pub cursor: Option<String>,
pub per_page: u64,
}Expand description
Cursor-based pagination extractor
Extracts cursor pagination parameters from the query string.
Supports ?cursor=abc123&limit=20 (defaults: cursor=None, limit=20, max=100).
Cursor-based pagination is preferred for large datasets or real-time data where offset-based pagination would skip or duplicate items.
§Example
ⓘ
use rustapi_core::CursorPaginate;
async fn list_events(cursor: CursorPaginate) -> impl IntoResponse {
let limit = cursor.limit();
if let Some(after) = cursor.after() {
// SELECT * FROM events WHERE id > $after ORDER BY id LIMIT $limit
} else {
// SELECT * FROM events ORDER BY id LIMIT $limit
}
}Fields§
§cursor: Option<String>Opaque cursor token (None = start from beginning)
per_page: u64Items per page (capped at MAX_PER_PAGE)
Implementations§
Trait Implementations§
Source§impl Clone for CursorPaginate
impl Clone for CursorPaginate
Source§fn clone(&self) -> CursorPaginate
fn clone(&self) -> CursorPaginate
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 CursorPaginate
impl Debug for CursorPaginate
Source§impl Default for CursorPaginate
impl Default for CursorPaginate
Source§impl FromRequestParts for CursorPaginate
impl FromRequestParts for CursorPaginate
Source§fn from_request_parts(req: &Request) -> Result<Self>
fn from_request_parts(req: &Request) -> Result<Self>
Extract from request parts
Auto Trait Implementations§
impl Freeze for CursorPaginate
impl RefUnwindSafe for CursorPaginate
impl Send for CursorPaginate
impl Sync for CursorPaginate
impl Unpin for CursorPaginate
impl UnsafeUnpin for CursorPaginate
impl UnwindSafe for CursorPaginate
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