pub trait FromRequest<S, B = BoxBody>: Sized {
type Rejection: IntoResponse;
type Future: Future<Output = Result<Self, Self::Rejection>> + Send;
// Required method
fn from_request(req: Request<B>, state: &S) -> Self::Future;
}Expand description
Extract a typed value that may need the request body (e.g. Json<T>).
Only one FromRequest extractor may appear per handler, and it must be
the last argument, since it consumes the body.
Required Associated Types§
Sourcetype Rejection: IntoResponse
type Rejection: IntoResponse
The response returned when extraction fails.
Required Methods§
Sourcefn from_request(req: Request<B>, state: &S) -> Self::Future
fn from_request(req: Request<B>, state: &S) -> Self::Future
Perform the extraction, consuming the request.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl<S: Clone + Send + 'static> FromRequest<S> for State<S>
State also implements FromRequest so it can be the last argument
in a multi-extractor handler tuple. The body is split off and dropped.
impl<S: Clone + Send + 'static> FromRequest<S> for State<S>
State also implements FromRequest so it can be the last argument
in a multi-extractor handler tuple. The body is split off and dropped.