Trait axum::extract::FromRequestParts
source · pub trait FromRequestParts<S>: Sized {
type Rejection: IntoResponse;
// Required method
fn from_request_parts<'life0, 'life1, 'async_trait>(
parts: &'life0 mut Parts,
state: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Rejection>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
}
Expand description
Types that can be created from request parts.
Extractors that implement FromRequestParts
cannot consume the request body and can thus be
run in any order for handlers.
If your extractor needs to consume the request body then you should implement FromRequest
and not FromRequestParts
.
See axum::extract
for more general docs about extractors.
Required Associated Types§
sourcetype 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§
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl<S> FromRequestParts<S> for ()
impl<S> FromRequestParts<S> for ()
type Rejection = Infallible
fn from_request_parts<'life0, 'life1, 'async_trait>(
_: &'life0 mut Parts,
_: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<(), <() as FromRequestParts<S>>::Rejection>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
(): 'async_trait,
source§impl<S> FromRequestParts<S> for Extensions
impl<S> FromRequestParts<S> for Extensions
type Rejection = Infallible
fn from_request_parts<'life0, 'life1, 'async_trait>(
parts: &'life0 mut Parts,
_state: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Extensions, <Extensions as FromRequestParts<S>>::Rejection>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Extensions: 'async_trait,
source§impl<S> FromRequestParts<S> for HeaderMap
impl<S> FromRequestParts<S> for HeaderMap
Clone the headers from the request.
Prefer using TypedHeader
to extract only the headers you need.