Skip to main content

FromOwnedRequestParts

Trait FromOwnedRequestParts 

pub trait FromOwnedRequestParts:
    Sized
    + Send
    + 'static {
    type Rejection;

    // Required method
    fn from_owned_request_parts(
        parts: Parts,
    ) -> impl Future<Output = Result<Self, Self::Rejection>> + Send + 'static;
}
Available on crate features http and std only.
Expand description

Types that can be created by consuming the request parts.

Exactly one owned-parts extractor can be used, either as the final handler argument or immediately before a trailing FromRequestBody extractor. Implementors automatically implement FromRequest for the terminal case. Unlike FromPartsStateRefPair, this trait can move fields out of Parts without cloning them. When followed by a body extractor, the body extractor first prepares an owned future from borrowed parts, the owned-parts extractor runs, and only then is the body future awaited. This preserves argument-order rejection precedence without retaining or cloning the parts.

HeaderMap, Parts, Extensions, and Uri implement this trait.

§Example

use rama_http::{HeaderMap, StatusCode};
use rama_http::service::web::{WebService, extract::Text};

let _service = WebService::default().with_post(
    "/",
    async |_headers: HeaderMap, Text(_payload): Text| StatusCode::OK,
);

Required Associated Types§

type Rejection

If the extractor fails it’ll use this rejection type.

Required Methods§

fn from_owned_request_parts( parts: Parts, ) -> impl Future<Output = Result<Self, Self::Rejection>> + Send + 'static

Perform the extraction by consuming the request parts.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§