Skip to main content

FromRequestParts

Trait FromRequestParts 

Source
pub trait FromRequestParts: Sized + Send {
    const BACKGROUND_TASKS: bool = false;

    // Required method
    fn from_request_parts(
        parts: &mut Parts,
    ) -> impl Future<Output = Result<Self, ApiError>> + Send;

    // Provided method
    fn describe(_op: &mut Operation, _registry: &mut SchemaRegistry) { ... }
}
Expand description

Extract a value from request metadata (method, URI, headers, extensions).

Provided Associated Constants§

Source

const BACKGROUND_TASKS: bool = false

Whether extraction needs a request-owned background queue. Custom wrappers delegating to BackgroundTasks must propagate this.

Required Methods§

Source

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

Perform the extraction.

Provided Methods§

Source

fn describe(_op: &mut Operation, _registry: &mut SchemaRegistry)

Document this extractor on op (parameters, security, …).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: FromRequestParts> FromRequestParts for Option<T>

Optional extraction: None when the input is absent, the error otherwise.

Only errors marked ApiError::absent become None; a header, query string or credential that is present but invalid still fails the request.

Source§

fn describe(op: &mut Operation, registry: &mut SchemaRegistry)

Documents T, with everything it adds marked optional. Security schemes it requires become an alternative next to the requirements that held before.

Source§

const BACKGROUND_TASKS: bool = T::BACKGROUND_TASKS

Source§

async fn from_request_parts(parts: &mut Parts) -> Result<Self, ApiError>

Implementors§