Skip to main content

FromRequest

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

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( req: Request<Body>, 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, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> FromRequest<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> FromRequest<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> FromRequest<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> FromRequest<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> FromRequest<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> FromRequest<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> FromRequest<S> for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

§

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

§

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

§

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

§

type Rejection = Response<Body>

§

fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<(T1, T2, T3, T4, T5, T6, T7), <(T1, T2, T3, T4, T5, T6, T7) as FromRequest<S>>::Rejection>>

§

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

§

type Rejection = Response<Body>

§

fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<(T1, T2, T3, T4, T5, T6), <(T1, T2, T3, T4, T5, T6) as FromRequest<S>>::Rejection>>

§

impl<S, T1, T2, T3, T4, T5> FromRequest<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: FromRequest<S> + Send, S: Send + Sync,

§

type Rejection = Response<Body>

§

fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<(T1, T2, T3, T4, T5), <(T1, T2, T3, T4, T5) as FromRequest<S>>::Rejection>>

§

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

§

type Rejection = Response<Body>

§

fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<(T1, T2, T3, T4), <(T1, T2, T3, T4) as FromRequest<S>>::Rejection>>

§

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

§

type Rejection = Response<Body>

§

fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<(T1, T2, T3), <(T1, T2, T3) as FromRequest<S>>::Rejection>>

§

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

§

type Rejection = Response<Body>

§

fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<(T1, T2), <(T1, T2) as FromRequest<S>>::Rejection>>

§

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

§

type Rejection = Response<Body>

§

fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<(T1,), <(T1,) as FromRequest<S>>::Rejection>>

§

impl<S, T> FromRequest<S> for Option<T>
where T: OptionalFromRequest<S>, S: Send + Sync,

§

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

§

async fn from_request( req: Request<Body>, state: &S, ) -> Result<Option<T>, <Option<T> as FromRequest<S>>::Rejection>

§

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

§

type Rejection = Infallible

§

async fn from_request( req: Request<Body>, state: &S, ) -> Result<Result<T, <T as FromRequest<S>>::Rejection>, <Result<T, <T as FromRequest<S>>::Rejection> as FromRequest<S>>::Rejection>

§

impl<S> FromRequest<S> for Bytes
where S: Send + Sync,

§

type Rejection = BytesRejection

§

async fn from_request( req: Request<Body>, _: &S, ) -> Result<Bytes, <Bytes as FromRequest<S>>::Rejection>

§

impl<S> FromRequest<S> for BytesMut
where S: Send + Sync,

§

type Rejection = BytesRejection

§

async fn from_request( req: Request<Body>, _: &S, ) -> Result<BytesMut, <BytesMut as FromRequest<S>>::Rejection>

§

impl<S> FromRequest<S> for Request<Body>
where S: Send + Sync,

§

type Rejection = Infallible

§

async fn from_request( req: Request<Body>, _: &S, ) -> Result<Request<Body>, <Request<Body> as FromRequest<S>>::Rejection>

§

impl<S> FromRequest<S> for String
where S: Send + Sync,

§

type Rejection = StringRejection

§

async fn from_request( req: Request<Body>, state: &S, ) -> Result<String, <String as FromRequest<S>>::Rejection>

Implementors§

§

impl<S, T> FromRequest<S, ViaParts> for T
where S: Send + Sync, T: FromRequestParts<S>,

§

impl<S> FromRequest<S> for Body
where S: Send + Sync,

§

impl<S> FromRequest<S> for RawForm
where S: Send + Sync,

§

impl<T, S> FromRequest<S> for Form<T>
where T: DeserializeOwned, S: Send + Sync,

§

impl<T, S> FromRequest<S> for Json<T>
where T: DeserializeOwned, S: Send + Sync,