pub struct PageParams {
pub limit: Option<i64>,
pub offset: Option<i64>,
}Expand description
The page window a list endpoint accepts.
Fields§
§limit: Option<i64>§offset: Option<i64>Implementations§
Source§impl PageParams
impl PageParams
Sourcepub fn from(limit: Option<i64>, offset: Option<i64>) -> Self
pub fn from(limit: Option<i64>, offset: Option<i64>) -> Self
Builds a window from fields a caller declared inline.
Sourcepub fn resolve(&self, config: &Config) -> Page
pub fn resolve(&self, config: &Config) -> Page
Clamps the caller’s window into something the database can be handed.
Clamped rather than refused: a ?limit=100000 is far more likely to be
a client that does not know the ceiling than an attack, and answering
with the largest allowed page is more useful than a 400. A negative
offset is nonsense, so it becomes 0 rather than a SQL error.
The upper clamp is not cosmetic: pages::pager computes
offset + limit to place the “next” link, and ?offset= arrives
straight off the query string as an i64. At i64::MAX that addition
overflows — a panic in a debug build, a silent wrap to a negative page
window in release, which sets no overflow-checks. [MAX_OFFSET]
leaves headroom for the addition no matter what limit resolved to.
Trait Implementations§
Source§impl Debug for PageParams
impl Debug for PageParams
Source§impl Default for PageParams
impl Default for PageParams
Source§impl<'de> Deserialize<'de> for PageParams
impl<'de> Deserialize<'de> for PageParams
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for PageParams
impl RefUnwindSafe for PageParams
impl Send for PageParams
impl Sync for PageParams
impl Unpin for PageParams
impl UnsafeUnpin for PageParams
impl UnwindSafe for PageParams
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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> ⓘ
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