Struct seamless::handler::body::FromJson [−][src]
pub struct FromJson<T: ApiBody>(pub T);
Expand description
If the last argument to a handler is this, we’ll assume
that the user needs to provide JSON that decodes to T
.
Notably, T
needs to implement ApiBody
with the
Deserialize option.
Tuple Fields
0: T
Trait Implementations
This returns information about the shape of the type and description of parts of it.
Serialize the type to JSON.
Serialize the type to a serde_json::Value
.
Deserialize from bytes containing a JSON value.
Deserialize from a serde_json::Value
.
fn handler_body<'life0, 'async_trait>(
req: Request<&'life0 mut dyn AsyncReadBody>
) -> Pin<Box<dyn Future<Output = Result<Self, ApiError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn handler_body<'life0, 'async_trait>(
req: Request<&'life0 mut dyn AsyncReadBody>
) -> Pin<Box<dyn Future<Output = Result<Self, ApiError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Given a request containing arbitrary bytes, this function needs to return an instance of the type that this trait is implemented on (typically by deserializing it from the bytes provided), or else it should return an error describing what went wrong. Read more
Which HTTP method is required for this Body to be valid. By default, if a body is present in the handler we’ll expect the method to be POST. Implement this function to override that. Read more