pub trait Extract<B: BufStream>: 'static + Sized {
type Future: ExtractFuture<Item = Self>;
// Required method
fn extract(context: &Context<'_>) -> Self::Future;
// Provided methods
fn extract_body(context: &Context<'_>, body: B) -> Self::Future { ... }
fn requires_body(callsite: &CallSite) -> bool { ... }
}Expand description
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.
Required Associated Types§
Sourcetype Future: ExtractFuture<Item = Self>
type Future: ExtractFuture<Item = Self>
The future representing the completion of the extraction logic.
Required Methods§
Provided Methods§
Sourcefn extract_body(context: &Context<'_>, body: B) -> Self::Future
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.
Sourcefn requires_body(callsite: &CallSite) -> bool
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.
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.