pub struct ListResponse<T: Serialize> {
pub data: Vec<T>,
pub total: i64,
pub limit: u32,
pub offset: u32,
}Expand description
A generic paginated collection response.
Serializes as:
{ "data": [...], "total": 42, "limit": 50, "offset": 0 }§Example
use axum::response::IntoResponse;
use axum_api_kit::ListResponse;
use serde::Serialize;
#[derive(Serialize)]
struct Item { id: String }
async fn list_items() -> impl IntoResponse {
ListResponse {
data: vec![Item { id: "1".into() }],
total: 1,
limit: 50,
offset: 0,
}
}Fields§
§data: Vec<T>The items in this page.
total: i64Total number of matching items across all pages.
limit: u32Maximum number of items per page (as requested).
offset: u32Zero-based offset of the first item in this page.
Trait Implementations§
Source§impl<T: Clone + Serialize> Clone for ListResponse<T>
impl<T: Clone + Serialize> Clone for ListResponse<T>
Source§fn clone(&self) -> ListResponse<T>
fn clone(&self) -> ListResponse<T>
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<T> ComposeSchema for ListResponse<T>
impl<T> ComposeSchema for ListResponse<T>
Source§impl<T: Serialize> IntoResponse for ListResponse<T>
impl<T: Serialize> IntoResponse for ListResponse<T>
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Create a response.
Source§impl<T> Serialize for ListResponse<T>
impl<T> Serialize for ListResponse<T>
Auto Trait Implementations§
impl<T> Freeze for ListResponse<T>
impl<T> RefUnwindSafe for ListResponse<T>where
T: RefUnwindSafe,
impl<T> Send for ListResponse<T>where
T: Send,
impl<T> Sync for ListResponse<T>where
T: Sync,
impl<T> Unpin for ListResponse<T>where
T: Unpin,
impl<T> UnsafeUnpin for ListResponse<T>
impl<T> UnwindSafe for ListResponse<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, S> Handler<IntoResponseHandler, S> for T
impl<T, S> Handler<IntoResponseHandler, S> for T
Source§fn call(
self,
_req: Request<Body>,
_state: S,
) -> <T as Handler<IntoResponseHandler, S>>::Future
fn call( self, _req: Request<Body>, _state: S, ) -> <T as Handler<IntoResponseHandler, S>>::Future
Call the handler with the given request.
Source§fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
Apply a
tower::Layer to the handler. Read moreSource§fn with_state(self, state: S) -> HandlerService<Self, T, S>
fn with_state(self, state: S) -> HandlerService<Self, T, S>
Convert the handler into a
Service by providing the stateSource§impl<H, T> HandlerWithoutStateExt<T> for H
impl<H, T> HandlerWithoutStateExt<T> for H
Source§fn into_service(self) -> HandlerService<H, T, ()>
fn into_service(self) -> HandlerService<H, T, ()>
Convert the handler into a
Service and no state.Source§fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
Convert the handler into a
MakeService and no state. Read moreSource§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