Trait FromRequest
pub trait FromRequest<S, M = ViaRequest>: Sized {
type Rejection: IntoResponse;
// Required method
fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<Self, Self::Rejection>> + Send;
}
Expand description
Types that can be created from requests.
Extractors that implement FromRequest
can consume the request body and can thus only be run
once for handlers.
If your extractor doesnโt need to consume the request body then you should implement
FromRequestParts
and not FromRequest
.
See axum::extract
for more general docs about extractors.
Required Associated Typesยง
type Rejection: IntoResponse
type Rejection: IntoResponse
If the extractor fails itโll use this โrejectionโ type. A rejection is a kind of error that can be converted into a response.
Required Methodsยง
Dyn Compatibilityยง
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.