pub struct OffsetPage { /* private fields */ }Expand description
Normalized offset-page result.
Constructed only via build_page or build_offset_page — the inner
fields are private to prevent hand-rolled construction. Call
OffsetPage::into_parts to destructure into the four values needed to
populate a proto response message.
§Why a newtype?
The private constructor is the enforcement mechanism (ADR-0096 §Enforcement
Level 1): call sites that expect OffsetPage cannot be satisfied with an
inline-built response struct, making the canonical builder mandatory at
compile time.
Implementations§
Source§impl OffsetPage
impl OffsetPage
Sourcepub fn into_parts(self) -> (u64, bool, u64, u64)
pub fn into_parts(self) -> (u64, bool, u64, u64)
Destructure into (total_count, has_more, limit, offset).
Use these values to populate the page field of a proto response:
ⓘ
let page = build_page(req.page.limit, req.page.offset, items.len(), total);
let (total_count, has_more, limit, offset) = page.into_parts();
response.page = SomeOffsetPageResponse { total_count, has_more, limit, offset, .. };Sourcepub fn total_count(&self) -> u64
pub fn total_count(&self) -> u64
Total number of items across all pages.
Trait Implementations§
Source§impl Clone for OffsetPage
impl Clone for OffsetPage
Source§fn clone(&self) -> OffsetPage
fn clone(&self) -> OffsetPage
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 OffsetPage
impl Debug for OffsetPage
Source§impl PartialEq for OffsetPage
impl PartialEq for OffsetPage
Source§fn eq(&self, other: &OffsetPage) -> bool
fn eq(&self, other: &OffsetPage) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for OffsetPage
impl StructuralPartialEq for OffsetPage
Auto Trait Implementations§
impl Freeze for OffsetPage
impl RefUnwindSafe for OffsetPage
impl Send for OffsetPage
impl Sync for OffsetPage
impl Unpin for OffsetPage
impl UnsafeUnpin for OffsetPage
impl UnwindSafe for OffsetPage
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