pub struct JsonResponse<D = Value, M = DefaultMeta> {
pub data: Option<D>,
pub errors: Vec<ErrorObject>,
pub meta: Option<M>,
pub status_code: u16,
}Expand description
A response object folling the jsonapi format.
§Note // TODO: Address these inconsistencies
This is mostly a scratch, relying in the serde_json::Value for certain scenarios
Also it does not restrict the Self::data variant (see https://jsonapi.org/format/#document-top-level for how it should look).
Fields§
§data: Option<D>§errors: Vec<ErrorObject>§meta: Option<M>§status_code: u16Implementations§
Source§impl JsonResponse<(), Value>
impl JsonResponse<(), Value>
Source§impl<D> JsonResponse<D>
impl<D> JsonResponse<D>
Trait Implementations§
Source§impl<D: Clone, M: Clone> Clone for JsonResponse<D, M>
impl<D: Clone, M: Clone> Clone for JsonResponse<D, M>
Source§fn clone(&self) -> JsonResponse<D, M>
fn clone(&self) -> JsonResponse<D, M>
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<D, M> Default for JsonResponse<D, M>
impl<D, M> Default for JsonResponse<D, M>
Source§impl<'de, D, M> Deserialize<'de> for JsonResponse<D, M>
impl<'de, D, M> Deserialize<'de> for JsonResponse<D, M>
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<D: Serialize, M: Serialize> IntoResponse for JsonResponse<D, M>
impl<D: Serialize, M: Serialize> IntoResponse for JsonResponse<D, M>
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Create a response.
Auto Trait Implementations§
impl<D, M> Freeze for JsonResponse<D, M>
impl<D, M> RefUnwindSafe for JsonResponse<D, M>where
D: RefUnwindSafe,
M: RefUnwindSafe,
impl<D, M> Send for JsonResponse<D, M>
impl<D, M> Sync for JsonResponse<D, M>
impl<D, M> Unpin for JsonResponse<D, M>
impl<D, M> UnsafeUnpin for JsonResponse<D, M>where
D: UnsafeUnpin,
M: UnsafeUnpin,
impl<D, M> UnwindSafe for JsonResponse<D, M>where
D: UnwindSafe,
M: 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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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§fn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
Convert the handler into a
MakeService which stores information
about the incoming connection and has no state. Read more