pub trait FromRequest:
Sized
+ Send
+ 'static {
// Required method
fn from_request(
request: Arc<Request>,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send>>;
}Expand description
Something a handler parameter can be built from.
Required Methods§
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 FromRequest for TokenAbilities
impl FromRequest for TokenAbilities
Source§impl<T> FromRequest for Option<T>where
T: FromRequest,
An extractor that never fails: Option<T> is None when T would have
errored. For inputs that are genuinely optional.
impl<T> FromRequest for Option<T>where
T: FromRequest,
An extractor that never fails: Option<T> is None when T would have
errored. For inputs that are genuinely optional.
Source§impl<T> FromRequest for Result<T, Error>where
T: FromRequest,
Hands the extraction error to the handler instead of short-circuiting, for
actions that want to answer a bad request themselves.
impl<T> FromRequest for Result<T, Error>where
T: FromRequest,
Hands the extraction error to the handler instead of short-circuiting, for actions that want to answer a bad request themselves.
Implementors§
impl FromRequest for Arc<Request>
The whole request.
impl FromRequest for Bearer
impl FromRequest for RawBody
impl<K> FromRequest for Files<K>where
K: StaticName,
impl<K> FromRequest for Header<K>where
K: StaticName,
impl<M: Model, K: ParamKey> FromRequest for BoundAs<M, K>
impl<M: Model> FromRequest for Bound<M>
impl<T> FromRequest for Form<T>where
T: DeserializeOwned + Send + 'static,
impl<T> FromRequest for Json<T>where
T: DeserializeOwned + Send + 'static,
impl<T> FromRequest for Path<T>where
T: DeserializeOwned + Send + 'static,
impl<T> FromRequest for Query<T>where
T: DeserializeOwned + Send + 'static,
impl<T> FromRequest for Validated<T>where
T: FormRequest,
impl<U> FromRequest for AuthenticatedUser<U>
The authenticated user, as a controller parameter.
The framework supplies it, which is why an action can read
pub async fn me(user: AuthenticatedUser<User>) -> Result<Response> {
Ok(Response::json(user.get()))
}rather than taking the whole request and digging the user out of it.
Fails with 401 when there is none — which can only happen on a route with
no Authenticate middleware in front, so the message says so rather than
blaming the caller for a wiring mistake.