pub struct Paginate {
pub page: u64,
pub per_page: u64,
}Expand description
Offset-based pagination extractor
Extracts pagination parameters from the query string.
Supports ?page=1&per_page=20 (defaults: page=1, per_page=20, max=100).
§Example
ⓘ
use rustapi_core::Paginate;
async fn list_users(paginate: Paginate) -> impl IntoResponse {
let offset = paginate.offset();
let limit = paginate.limit();
// SELECT * FROM users LIMIT $limit OFFSET $offset
}Fields§
§page: u64Current page (1-indexed)
per_page: u64Items per page (capped at MAX_PER_PAGE)
Implementations§
Trait Implementations§
Source§impl FromRequestParts for Paginate
impl FromRequestParts for Paginate
Source§fn from_request_parts(req: &Request) -> Result<Self>
fn from_request_parts(req: &Request) -> Result<Self>
Extract from request parts
impl Copy for Paginate
Auto Trait Implementations§
impl Freeze for Paginate
impl RefUnwindSafe for Paginate
impl Send for Paginate
impl Sync for Paginate
impl Unpin for Paginate
impl UnsafeUnpin for Paginate
impl UnwindSafe for Paginate
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