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§
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.
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.
async fn from_request(ctx: &mut RequestCtx) -> Result<Self>
Implementors§
impl FromRequest for Headers
impl FromRequest for Multipart
impl FromRequest for PathParams
impl FromRequest for RawBody
impl<A: PathParam, B: PathParam, C: PathParam> FromRequest for Path<(A, B, C)>
impl<A: PathParam, B: PathParam> FromRequest for Path<(A, B)>
impl<T: DeserializeOwned + Send> FromRequest for Json<T>
impl<T: DeserializeOwned + Send> FromRequest for Query<T>
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.