[][src]Trait tower_web::extract::Extract

pub trait Extract<B: BufStream>: 'static + Sized {
    type Future: ExtractFuture<Item = Self>;
    fn extract(context: &Context) -> Self::Future;

    fn extract_body(context: &Context, body: B) -> Self::Future { ... }
fn requires_body(callsite: &CallSite) -> bool { ... } }

Extract a value from an HTTP request.

The extracted value does not need to be produced immediately. Implementations of Extract are able to perform asynchronous processing.

The trait is generic over B: BufStream, which represents the HTTP request body stream.

Associated Types

type Future: ExtractFuture<Item = Self>

The future representing the completion of the extraction logic.

Loading content...

Required methods

fn extract(context: &Context) -> Self::Future

Extract the argument from the HTTP request.

This function is not provide the HTTP request body. Implementations of this function must ensure that the request HEAD (request URI and headers) are sufficient for extracting the value.

Loading content...

Provided methods

fn extract_body(context: &Context, body: B) -> Self::Future

Extract the argument using the HTTP request body.

Doing so will usually involve deserializing the contents of the HTTP request body to the target value being extracted.

fn requires_body(callsite: &CallSite) -> bool

Returns true if extracting the type requires body.

Only a single resource method argument may extract using the HTTP request body. This function allows enforcing this requirement.

Loading content...

Implementations on Foreign Types

impl<B: BufStream> Extract<B> for Vec<u8>[src]

type Future = ExtractBytes<Self, B>

impl<B: BufStream> Extract<B> for u8[src]

type Future = Immediate<u8>

fn extract_body(context: &Context, body: B) -> Self::Future[src]

fn requires_body(callsite: &CallSite) -> bool[src]

impl<B: BufStream> Extract<B> for u16[src]

type Future = Immediate<u16>

fn extract_body(context: &Context, body: B) -> Self::Future[src]

fn requires_body(callsite: &CallSite) -> bool[src]

impl<B: BufStream> Extract<B> for u32[src]

type Future = Immediate<u32>

fn extract_body(context: &Context, body: B) -> Self::Future[src]

fn requires_body(callsite: &CallSite) -> bool[src]

impl<B: BufStream> Extract<B> for u64[src]

type Future = Immediate<u64>

fn extract_body(context: &Context, body: B) -> Self::Future[src]

fn requires_body(callsite: &CallSite) -> bool[src]

impl<B: BufStream> Extract<B> for i8[src]

type Future = Immediate<i8>

fn extract_body(context: &Context, body: B) -> Self::Future[src]

fn requires_body(callsite: &CallSite) -> bool[src]

impl<B: BufStream> Extract<B> for i16[src]

type Future = Immediate<i16>

fn extract_body(context: &Context, body: B) -> Self::Future[src]

fn requires_body(callsite: &CallSite) -> bool[src]

impl<B: BufStream> Extract<B> for i32[src]

type Future = Immediate<i32>

fn extract_body(context: &Context, body: B) -> Self::Future[src]

fn requires_body(callsite: &CallSite) -> bool[src]

impl<B: BufStream> Extract<B> for i64[src]

type Future = Immediate<i64>

fn extract_body(context: &Context, body: B) -> Self::Future[src]

fn requires_body(callsite: &CallSite) -> bool[src]

impl<T, B: BufStream> Extract<B> for Option<T> where
    T: Extract<B>, 
[src]

type Future = ExtractOptionFuture<T::Future>

fn extract_body(context: &Context, body: B) -> Self::Future[src]

fn requires_body(callsite: &CallSite) -> bool[src]

impl<B: BufStream> Extract<B> for PathBuf[src]

type Future = Immediate<Self>

fn extract_body(context: &Context, body: B) -> Self::Future[src]

fn requires_body(callsite: &CallSite) -> bool[src]

impl<B: BufStream> Extract<B> for Value[src]

type Future = SerdeFuture<Self, B>

impl<B: BufStream> Extract<B> for String[src]

type Future = ExtractString<B>

impl<B: BufStream> Extract<B> for OsString[src]

type Future = Immediate<Self>

fn extract_body(context: &Context, body: B) -> Self::Future[src]

fn requires_body(callsite: &CallSite) -> bool[src]

Loading content...

Implementors

impl<B: BufStream> Extract<B> for HttpDateTime[src]

type Future = Immediate<HttpDateTime>

fn extract_body(context: &Context, body: B) -> Self::Future[src]

fn requires_body(callsite: &CallSite) -> bool[src]

Loading content...