pub struct Page<T: JsonSchema> {
pub items: Vec<T>,
pub page: u32,
pub per_page: u32,
pub total: u64,
pub total_pages: u64,
pub has_next: bool,
pub has_prev: bool,
}Expand description
A page of results plus the metadata a client needs to walk the rest.
Fields§
§items: Vec<T>The items on this page.
page: u321-based page number these items came from.
per_page: u32Page size used for this query.
total: u64Total number of items across all pages.
total_pages: u64Total number of pages given total and per_page (at least 1).
has_next: boolWhether a next page exists.
has_prev: boolWhether a previous page exists.
Implementations§
Source§impl<T: JsonSchema> Page<T>
impl<T: JsonSchema> Page<T>
Sourcepub fn new(items: Vec<T>, params: PageParams, total: u64) -> Self
pub fn new(items: Vec<T>, params: PageParams, total: u64) -> Self
Build a response envelope from a fetched slice, the request’s
PageParams, and the total row count.
Trait Implementations§
Source§impl<T: JsonSchema + JsonSchema> JsonSchema for Page<T>
impl<T: JsonSchema + JsonSchema> JsonSchema for Page<T>
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreAuto Trait Implementations§
impl<T> Freeze for Page<T>
impl<T> RefUnwindSafe for Page<T>where
T: RefUnwindSafe,
impl<T> Send for Page<T>where
T: Send,
impl<T> Sync for Page<T>where
T: Sync,
impl<T> Unpin for Page<T>where
T: Unpin,
impl<T> UnsafeUnpin for Page<T>
impl<T> UnwindSafe for Page<T>where
T: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request