Skip to main content

OptionalFromRequest

Trait OptionalFromRequest 

Source
pub trait OptionalFromRequest<S, M = ViaRequest>: Sized {
    type Rejection: IntoResponse;

    // Required method
    fn from_request(
        req: Request<Body>,
        state: &S,
    ) -> impl Future<Output = Result<Option<Self>, Self::Rejection>> + Send;
}
Expand description

Customize the behavior of Option<Self> as a FromRequest extractor.

Required Associated Types§

Source

type Rejection: IntoResponse

If the extractor fails, it will 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<Body>, state: &S, ) -> impl Future<Output = Result<Option<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".

Implementors§