Trait tower_web::extract::Extract [−][src]
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.
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.
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.
Implementations on Foreign Types
impl<B: BufStream> Extract<B> for Vec<u8>[src]
impl<B: BufStream> Extract<B> for Vec<u8>impl<B: BufStream> Extract<B> for u32[src]
impl<B: BufStream> Extract<B> for u32impl<T, B: BufStream> Extract<B> for Option<T> where
T: Extract<B>, [src]
impl<T, B: BufStream> Extract<B> for Option<T> where
T: Extract<B>, type Future = ExtractOptionFuture<T::Future>
fn extract(ctx: &Context) -> Self::Future[src]
fn extract(ctx: &Context) -> Self::Futurefn extract_body(context: &Context, body: B) -> Self::Future[src]
fn extract_body(context: &Context, body: B) -> Self::Futurefn requires_body(callsite: &CallSite) -> bool[src]
fn requires_body(callsite: &CallSite) -> boolimpl<B: BufStream> Extract<B> for PathBuf[src]
impl<B: BufStream> Extract<B> for PathBufimpl<B: BufStream> Extract<B> for String[src]
impl<B: BufStream> Extract<B> for StringImplementors
impl<B: BufStream> Extract<B> for HttpDateTime type Future = Immediate<HttpDateTime>;