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 · 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromRequest for Twhere
T: FromRequestParts,
impl<T> FromRequest for Twhere
T: FromRequestParts,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more