Skip to main content

FromRequest

Trait FromRequest 

Source
pub trait FromRequest: Sized + Send {
    // Required method
    fn from_request(
        ctx: &mut RequestCtx,
    ) -> impl Future<Output = Result<Self>> + Send;
}
Expand description

Types that can be produced from the request. Implemented by all extractors and by Dep<T> (see dep module).

Required Methods§

Source

fn from_request( ctx: &mut RequestCtx, ) -> impl Future<Output = Result<Self>> + Send

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: FromRequest> FromRequest for Option<T>

Optional extraction: Some when the inner extractor succeeds, None on ANY extraction failure. For genuinely optional inputs — the canonical use is optional auth (Option<CurrentUser> on a route that also accepts a signed URL). Do NOT use it to paper over malformed required input: the failure reason is discarded by design — reach for Result<T, Error> when the failure must stay observable.

Source§

async fn from_request(ctx: &mut RequestCtx) -> Result<Self>

Implementors§

Source§

impl FromRequest for Headers

Source§

impl FromRequest for Multipart

Source§

impl FromRequest for PathParams

Source§

impl FromRequest for RawBody

Source§

impl<A: PathParam, B: PathParam, C: PathParam> FromRequest for Path<(A, B, C)>

Source§

impl<A: PathParam, B: PathParam> FromRequest for Path<(A, B)>

Source§

impl<T: DeserializeOwned + Send> FromRequest for Json<T>

Source§

impl<T: DeserializeOwned + Send> FromRequest for Query<T>

Source§

impl<T: FromRequest> FromRequest for Result<T, Error>

Error-PRESERVING optional extraction: Ok(v) when the inner extractor succeeds, Err(e) carrying ITS error when it fails — the extraction itself never fails the request, so the handler decides. For routes that accept more than one credential and must keep the guard’s real status when the fallback also misses (#109): a private tenant bucket’s download takes Result<Dep<Tenant>, Error> and, past the signed-URL branch, propagates with let tenant = tenant?; — a missing session stays 401 and a non-member’s guard failure stays 403, instead of Option<T> collapsing both into a rebound 401.

Source§

impl<T: PathParam> FromRequest for Path<T>

Source§

impl<T: Send + Sync + 'static> FromRequest for Dep<T>