Skip to main content

FromRequestParts

Trait FromRequestParts 

Source
pub trait FromRequestParts: Sized + Send {
    type Error: IntoResponse;

    // Required method
    fn from_request_parts(parts: &Parts) -> Result<Self, Self::Error>;
}
Expand description

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

Implementors can be used as handler arguments. Multiple FromRequestParts extractors can appear in a single handler since they don’t consume the body.

Required Associated Types§

Source

type Error: IntoResponse

The error type returned when extraction fails.

Required Methods§

Source

fn from_request_parts(parts: &Parts) -> Result<Self, Self::Error>

Extract this type from the request parts.

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 FromRequestParts for HeaderMap

Source§

impl FromRequestParts for Method

Extracts the HTTP method from the request.

Source§

impl FromRequestParts for Uri

Extracts the request URI.

Implementors§