pub trait Handler<T, S>:
Clone
+ Send
+ Sized
+ 'static {
type Future: Future<Output = Response> + Send + 'static;
// Required method
fn call(self, req: Request, state: S) -> Self::Future;
}Expand description
A request handler: any async function whose arguments are extractors,
and whose return type implements IntoResponse.
T is a marker type parameter used to disambiguate handler function
arities/argument types via blanket impls (see the impl for () below).
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl<F, Fut, R, S, A, B, C, D, E> Handler<(A, B, C, D, E), S> for Fwhere
F: Fn(A, B, C, D, E) -> Fut + Clone + Send + 'static,
Fut: Future<Output = R> + Send + 'static,
R: IntoResponse,
S: Clone + Send + 'static,
A: FromRequestParts<S> + Send + 'static,
B: FromRequestParts<S> + Send + 'static,
C: FromRequestParts<S> + Send + 'static,
D: FromRequestParts<S> + Send + 'static,
E: FromRequest<S, BoxBody> + Send + 'static,
5-argument handler: fn(A, B, C, D, E) -> Fut.
impl<F, Fut, R, S, A, B, C, D, E> Handler<(A, B, C, D, E), S> for Fwhere
F: Fn(A, B, C, D, E) -> Fut + Clone + Send + 'static,
Fut: Future<Output = R> + Send + 'static,
R: IntoResponse,
S: Clone + Send + 'static,
A: FromRequestParts<S> + Send + 'static,
B: FromRequestParts<S> + Send + 'static,
C: FromRequestParts<S> + Send + 'static,
D: FromRequestParts<S> + Send + 'static,
E: FromRequest<S, BoxBody> + Send + 'static,
5-argument handler: fn(A, B, C, D, E) -> Fut.
A, B, C, D are extracted via FromRequestParts; E is
extracted via FromRequest.
Source§impl<F, Fut, R, S, A, B, C, D> Handler<(A, B, C, D), S> for Fwhere
F: Fn(A, B, C, D) -> Fut + Clone + Send + 'static,
Fut: Future<Output = R> + Send + 'static,
R: IntoResponse,
S: Clone + Send + 'static,
A: FromRequestParts<S> + Send + 'static,
B: FromRequestParts<S> + Send + 'static,
C: FromRequestParts<S> + Send + 'static,
D: FromRequest<S, BoxBody> + Send + 'static,
4-argument handler: fn(A, B, C, D) -> Fut.
impl<F, Fut, R, S, A, B, C, D> Handler<(A, B, C, D), S> for Fwhere
F: Fn(A, B, C, D) -> Fut + Clone + Send + 'static,
Fut: Future<Output = R> + Send + 'static,
R: IntoResponse,
S: Clone + Send + 'static,
A: FromRequestParts<S> + Send + 'static,
B: FromRequestParts<S> + Send + 'static,
C: FromRequestParts<S> + Send + 'static,
D: FromRequest<S, BoxBody> + Send + 'static,
4-argument handler: fn(A, B, C, D) -> Fut.
A, B, and C are extracted via FromRequestParts; D is
extracted via FromRequest.
Source§impl<F, Fut, R, S, A, B, C> Handler<(A, B, C), S> for Fwhere
F: Fn(A, B, C) -> Fut + Clone + Send + 'static,
Fut: Future<Output = R> + Send + 'static,
R: IntoResponse,
S: Clone + Send + 'static,
A: FromRequestParts<S> + Send + 'static,
B: FromRequestParts<S> + Send + 'static,
C: FromRequest<S, BoxBody> + Send + 'static,
3-argument handler: fn(A, B, C) -> Fut.
impl<F, Fut, R, S, A, B, C> Handler<(A, B, C), S> for Fwhere
F: Fn(A, B, C) -> Fut + Clone + Send + 'static,
Fut: Future<Output = R> + Send + 'static,
R: IntoResponse,
S: Clone + Send + 'static,
A: FromRequestParts<S> + Send + 'static,
B: FromRequestParts<S> + Send + 'static,
C: FromRequest<S, BoxBody> + Send + 'static,
3-argument handler: fn(A, B, C) -> Fut.
A and B are extracted via FromRequestParts; C is extracted
via FromRequest. If any of A or B fails, the body is never
touched.
Source§impl<F, Fut, R, S, A, B> Handler<(A, B), S> for Fwhere
F: Fn(A, B) -> Fut + Clone + Send + 'static,
Fut: Future<Output = R> + Send + 'static,
R: IntoResponse,
S: Clone + Send + 'static,
A: FromRequestParts<S> + Send + 'static,
B: FromRequest<S, BoxBody> + Send + 'static,
2-argument handler: fn(A, B) -> Fut.
impl<F, Fut, R, S, A, B> Handler<(A, B), S> for Fwhere
F: Fn(A, B) -> Fut + Clone + Send + 'static,
Fut: Future<Output = R> + Send + 'static,
R: IntoResponse,
S: Clone + Send + 'static,
A: FromRequestParts<S> + Send + 'static,
B: FromRequest<S, BoxBody> + Send + 'static,
2-argument handler: fn(A, B) -> Fut.
A is extracted via FromRequestParts, B is extracted via
FromRequest. If A fails, the body is never touched.
Source§impl<F, Fut, R, S, E> Handler<(E,), S> for F
Blanket impl for handlers that take a single extractor argument.
impl<F, Fut, R, S, E> Handler<(E,), S> for F
Blanket impl for handlers that take a single extractor argument.
Any async fn F: Fn(E) -> Fut where Fut: Future<Output = R>,
R: IntoResponse, and E: FromRequest<S, BoxBody> is a valid handler.
The argument E is extracted via FromRequest::from_request, which
gets the full request (including body). For parts-only extractors the
blanket in extract.rs turns this into a simple parts extraction,
dropping the body. For body-consuming extractors (like [Json<T>]) the
body is read and deserialized as normal.
This single blanket replaces what were previously separate impls for
FromRequestParts (marker (E,)) and FromRequest (marker
(E, BoxBody)), because every FromRequestParts type now also
implements FromRequest via the blanket in extract.rs.