pub struct LxJson<T>(pub T);Expand description
A version of axum::Json which conforms to Lexe’s (JSON) API.
It can be used as either an extractor or a response.
- As an extractor: rejections return
LxRejection. - As a success response:
- Serialization success returns an
http::Responsewith JSON body. - Serialization failure returns a
ErrorResponse.
- Serialization success returns an
axum::Json is banned because:
- Rejections return
JsonRejectionwhich is just a string HTTP body. - Response serialization failures likewise return just a string body.
NOTE: This must only be used for forming success API responses,
i.e. T in Result<T, E>, because its IntoResponse impl uses
StatusCode::OK. Our API error types, while also serialized as JSON,
have separate IntoResponse impls which return error statuses.
Tuple Fields§
§0: TTrait Implementations§
Source§impl<T: DeserializeOwned, S: Send + Sync> FromRequest<S> for LxJson<T>
impl<T: DeserializeOwned, S: Send + Sync> FromRequest<S> for LxJson<T>
Source§impl<T: Serialize> IntoResponse for LxJson<T>
impl<T: Serialize> IntoResponse for LxJson<T>
Source§fn into_response(self) -> Response<Body>
fn into_response(self) -> Response<Body>
Create a response.
impl<T: Copy> Copy for LxJson<T>
impl<T: Eq + PartialEq> Eq for LxJson<T>
Auto Trait Implementations§
impl<T> Freeze for LxJson<T>where
T: Freeze,
impl<T> RefUnwindSafe for LxJson<T>where
T: RefUnwindSafe,
impl<T> Send for LxJson<T>where
T: Send,
impl<T> Sync for LxJson<T>where
T: Sync,
impl<T> Unpin for LxJson<T>where
T: Unpin,
impl<T> UnsafeUnpin for LxJson<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for LxJson<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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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 more