pub struct Pagination { /* private fields */ }
Implementations§
Source§impl Pagination
impl Pagination
Sourcepub fn new(page: u32, limit: u32, max_limit: Option<u32>) -> Self
pub fn new(page: u32, limit: u32, max_limit: Option<u32>) -> Self
Create new pagination
max_limit
is optional and will be clamped between PAGINATION_MIN_LIMIT
and PAGINATION_MAX_LIMIT
§Examples
use api_tools::value_objects::pagination::{Pagination, PAGINATION_MAX_LIMIT, PAGINATION_MIN_LIMIT};
let pagination = Pagination::new(1, 100, None);
assert_eq!(pagination.page(), 1);
assert_eq!(pagination.limit(), 100);
// Invalid page
let pagination = Pagination::new(0, 100, None);
assert_eq!(pagination.page(), 1);
assert_eq!(pagination.limit(), 100);
// Limit too small
let pagination = Pagination::new(2, 10, None);
assert_eq!(pagination.page(), 2);
assert_eq!(pagination.limit(), PAGINATION_MIN_LIMIT);
// Limit too big
let pagination = Pagination::new(2, 1_000, None);
assert_eq!(pagination.page(), 2);
assert_eq!(pagination.limit(), PAGINATION_MAX_LIMIT);
// Limit too big and max limit greater than max
let pagination = Pagination::new(2, 1_000, Some(800));
assert_eq!(pagination.page(), 2);
assert_eq!(pagination.limit(), PAGINATION_MAX_LIMIT);
Sourcepub fn set_max_limit(&mut self, max_limit: u32)
pub fn set_max_limit(&mut self, max_limit: u32)
Set a max limit (between PAGINATION_MIN_LIMIT
and PAGINATION_MAX_LIMIT
)
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 PartialEq for Pagination
impl PartialEq for Pagination
impl Eq for Pagination
impl StructuralPartialEq for Pagination
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.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> Pointable for T
impl<T> Pointable for T
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Add request id header and extension. Read more
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Add request id header and extension, using
x-request-id
as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Propgate request ids from requests to responses. Read more
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
Propgate request ids from requests to responses, using
x-request-id
as the header name. Read more