Skip to main content

FromRequestParts

Trait FromRequestParts 

pub trait FromRequestParts<S>: Sized {
    type Rejection: IntoResponse;

    // Required method
    fn from_request_parts(
        parts: &mut Parts,
        state: &S,
    ) -> impl Future<Output = Result<Self, Self::Rejection>> + Send;
}
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ยง

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ยง

fn from_request_parts( parts: &mut Parts, state: &S, ) -> impl Future<Output = Result<Self, Self::Rejection>> + Send

Perform the extraction.

Dyn Compatibilityยง

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Typesยง

ยง

impl<S, Backend> FromRequestParts<S> for AuthSession<Backend>
where S: Send + Sync, Backend: AuthnBackend + Send + Sync + 'static,

ยง

type Rejection = (StatusCode, &'static str)

ยง

async fn from_request_parts( parts: &mut Parts, _state: &S, ) -> Result<AuthSession<Backend>, <AuthSession<Backend> as FromRequestParts<S>>::Rejection>

ยง

impl<S, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> FromRequestParts<S> for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)

ยง

impl<S, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> FromRequestParts<S> for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)

ยง

impl<S, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> FromRequestParts<S> for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)

ยง

impl<S, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> FromRequestParts<S> for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)

ยง

impl<S, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> FromRequestParts<S> for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)

ยง

impl<S, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> FromRequestParts<S> for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

ยง

impl<S, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> FromRequestParts<S> for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

ยง

impl<S, T1, T2, T3, T4, T5, T6, T7, T8, T9> FromRequestParts<S> for (T1, T2, T3, T4, T5, T6, T7, T8, T9)

ยง

impl<S, T1, T2, T3, T4, T5, T6, T7, T8> FromRequestParts<S> for (T1, T2, T3, T4, T5, T6, T7, T8)

ยง

impl<S, T1, T2, T3, T4, T5, T6, T7> FromRequestParts<S> for (T1, T2, T3, T4, T5, T6, T7)

ยง

impl<S, T1, T2, T3, T4, T5, T6> FromRequestParts<S> for (T1, T2, T3, T4, T5, T6)

ยง

impl<S, T1, T2, T3, T4, T5> FromRequestParts<S> for (T1, T2, T3, T4, T5)
where T1: FromRequestParts<S> + Send, T2: FromRequestParts<S> + Send, T3: FromRequestParts<S> + Send, T4: FromRequestParts<S> + Send, T5: FromRequestParts<S> + Send, S: Send + Sync,

ยง

impl<S, T1, T2, T3, T4> FromRequestParts<S> for (T1, T2, T3, T4)
where T1: FromRequestParts<S> + Send, T2: FromRequestParts<S> + Send, T3: FromRequestParts<S> + Send, T4: FromRequestParts<S> + Send, S: Send + Sync,

ยง

type Rejection = Response<Body>

ยง

async fn from_request_parts( parts: &mut Parts, state: &S, ) -> Result<(T1, T2, T3, T4), <(T1, T2, T3, T4) as FromRequestParts<S>>::Rejection>

ยง

impl<S, T1, T2, T3> FromRequestParts<S> for (T1, T2, T3)
where T1: FromRequestParts<S> + Send, T2: FromRequestParts<S> + Send, T3: FromRequestParts<S> + Send, S: Send + Sync,

ยง

type Rejection = Response<Body>

ยง

async fn from_request_parts( parts: &mut Parts, state: &S, ) -> Result<(T1, T2, T3), <(T1, T2, T3) as FromRequestParts<S>>::Rejection>

ยง

impl<S, T1, T2> FromRequestParts<S> for (T1, T2)
where T1: FromRequestParts<S> + Send, T2: FromRequestParts<S> + Send, S: Send + Sync,

ยง

type Rejection = Response<Body>

ยง

async fn from_request_parts( parts: &mut Parts, state: &S, ) -> Result<(T1, T2), <(T1, T2) as FromRequestParts<S>>::Rejection>

ยง

impl<S, T1> FromRequestParts<S> for (T1,)
where T1: FromRequestParts<S> + Send, S: Send + Sync,

ยง

type Rejection = Response<Body>

ยง

async fn from_request_parts( parts: &mut Parts, state: &S, ) -> Result<(T1,), <(T1,) as FromRequestParts<S>>::Rejection>

ยง

impl<S, T> FromRequestParts<S> for Option<T>

ยง

type Rejection = <T as OptionalFromRequestParts<S>>::Rejection

ยง

fn from_request_parts( parts: &mut Parts, state: &S, ) -> impl Future<Output = Result<Option<T>, <Option<T> as FromRequestParts<S>>::Rejection>>

ยง

impl<S, T> FromRequestParts<S> for Result<T, <T as FromRequestParts<S>>::Rejection>
where T: FromRequestParts<S>, S: Send + Sync,

ยง

type Rejection = !

ยง

async fn from_request_parts( parts: &mut Parts, state: &S, ) -> Result<Result<T, <T as FromRequestParts<S>>::Rejection>, <Result<T, <T as FromRequestParts<S>>::Rejection> as FromRequestParts<S>>::Rejection>

ยง

impl<S> FromRequestParts<S> for ()
where S: Send + Sync,

ยง

type Rejection = !

ยง

async fn from_request_parts( _: &mut Parts, _: &S, ) -> Result<(), <() as FromRequestParts<S>>::Rejection>

ยง

impl<S> FromRequestParts<S> for Cookies
where S: Sync + Send,

ยง

type Rejection = (StatusCode, &'static str)

ยง

async fn from_request_parts( parts: &mut Parts, _state: &S, ) -> Result<Cookies, <Cookies as FromRequestParts<S>>::Rejection>

ยง

impl<S> FromRequestParts<S> for Extensions
where S: Send + Sync,

ยง

type Rejection = !

ยง

async fn from_request_parts( parts: &mut Parts, _state: &S, ) -> Result<Extensions, <Extensions as FromRequestParts<S>>::Rejection>

ยง

impl<S> FromRequestParts<S> for HeaderMap
where S: Send + Sync,

Clone the headers from the request.

Prefer using TypedHeader to extract only the headers you need.

ยง

type Rejection = !

ยง

async fn from_request_parts( parts: &mut Parts, _: &S, ) -> Result<HeaderMap, <HeaderMap as FromRequestParts<S>>::Rejection>

ยง

impl<S> FromRequestParts<S> for Method
where S: Send + Sync,

ยง

type Rejection = !

ยง

async fn from_request_parts( parts: &mut Parts, _: &S, ) -> Result<Method, <Method as FromRequestParts<S>>::Rejection>

ยง

impl<S> FromRequestParts<S> for Parts
where S: Send + Sync,

ยง

type Rejection = !

ยง

async fn from_request_parts( parts: &mut Parts, _state: &S, ) -> Result<Parts, <Parts as FromRequestParts<S>>::Rejection>

ยง

impl<S> FromRequestParts<S> for Session
where S: Sync + Send,

ยง

type Rejection = (StatusCode, &'static str)

ยง

async fn from_request_parts( parts: &mut Parts, _state: &S, ) -> Result<Session, <Session as FromRequestParts<S>>::Rejection>

ยง

impl<S> FromRequestParts<S> for Uri
where S: Send + Sync,

ยง

type Rejection = !

ยง

async fn from_request_parts( parts: &mut Parts, _: &S, ) -> Result<Uri, <Uri as FromRequestParts<S>>::Rejection>

ยง

impl<S> FromRequestParts<S> for Version
where S: Send + Sync,

ยง

type Rejection = !

ยง

async fn from_request_parts( parts: &mut Parts, _: &S, ) -> Result<Version, <Version as FromRequestParts<S>>::Rejection>

Implementorsยง

ยง

impl<OuterState, InnerState> FromRequestParts<OuterState> for State<InnerState>
where InnerState: FromRef<OuterState>, OuterState: Send + Sync,

ยง

impl<S, T> FromRequestParts<S> for ConnectInfo<T>
where S: Send + Sync, T: Clone + Send + Sync + 'static,

ยง

impl<S> FromRequestParts<S> for MatchedPath
where S: Send + Sync,

ยง

impl<S> FromRequestParts<S> for NestedPath
where S: Send + Sync,

ยง

impl<S> FromRequestParts<S> for OriginalUri
where S: Send + Sync,

ยง

impl<S> FromRequestParts<S> for RawPathParams
where S: Send + Sync,

ยง

impl<S> FromRequestParts<S> for RawQuery
where S: Send + Sync,

ยง

impl<S> FromRequestParts<S> for WebSocketUpgrade
where S: Send + Sync,

ยง

impl<T, S> FromRequestParts<S> for Extension<T>
where T: Clone + Send + Sync + 'static, S: Send + Sync,

ยง

impl<T, S> FromRequestParts<S> for Path<T>
where T: DeserializeOwned + Send, S: Send + Sync,

ยง

impl<T, S> FromRequestParts<S> for Query<T>
where T: DeserializeOwned, S: Send + Sync,