rama_http::service::web::extract

Trait FromRequest

Source
pub trait FromRequest:
    Sized
    + Send
    + Sync
    + 'static {
    type Rejection: IntoResponse;

    // Required method
    fn from_request(
        req: Request,
    ) -> 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.

Required Associated Types§

Source

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§

Source

fn from_request( req: Request, ) -> 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", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> FromRequest for Option<T>

Implementors§

Source§

impl FromRequest for Body

Source§

impl FromRequest for Bytes

Source§

type Rejection = BytesRejection

Source§

impl FromRequest for Text

Source§

type Rejection = TextRejection

Source§

impl FromRequest for Request

Source§

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

Source§

type Rejection = FormRejection

Source§

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

Source§

type Rejection = JsonRejection