Skip to main content

Handler

Trait Handler 

Source
pub trait Handler<Args>:
    Clone
    + Send
    + Sync
    + 'static {
    // Required method
    fn call(
        self,
        parts: Parts,
        body: Bytes,
    ) -> Pin<Box<dyn Future<Output = Response<BoxBody>> + Send>>;
}
Expand description

A handler that can process an HTTP request and produce a response.

Implemented automatically for async functions whose arguments are extractors. The Args type parameter encodes the extractor tuple and is used for trait resolution — users don’t specify it directly.

Required Methods§

Source

fn call( self, parts: Parts, body: Bytes, ) -> Pin<Box<dyn Future<Output = Response<BoxBody>> + Send>>

Call the handler with the given request parts and pre-collected body bytes.

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.

Implementors§

Source§

impl<F, Fut, Res> Handler<()> for F
where F: FnOnce() -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse,

Source§

impl<F, Fut, Res, B> Handler<WithBody<(), B>> for F
where F: FnOnce(B) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, B: FromRequest + 'static,

Source§

impl<F, Fut, Res, T1> Handler<(T1,)> for F
where F: FnOnce(T1) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static,

Source§

impl<F, Fut, Res, T1, B> Handler<WithBody<(T1,), B>> for F
where F: FnOnce(T1, B) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, B: FromRequest + 'static,

Source§

impl<F, Fut, Res, T1, T2> Handler<(T1, T2)> for F
where F: FnOnce(T1, T2) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static,

Source§

impl<F, Fut, Res, T1, T2, B> Handler<WithBody<(T1, T2), B>> for F
where F: FnOnce(T1, T2, B) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static, B: FromRequest + 'static,

Source§

impl<F, Fut, Res, T1, T2, T3> Handler<(T1, T2, T3)> for F
where F: FnOnce(T1, T2, T3) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static, T3: FromRequestParts + 'static,

Source§

impl<F, Fut, Res, T1, T2, T3, B> Handler<WithBody<(T1, T2, T3), B>> for F
where F: FnOnce(T1, T2, T3, B) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static, T3: FromRequestParts + 'static, B: FromRequest + 'static,

Source§

impl<F, Fut, Res, T1, T2, T3, T4> Handler<(T1, T2, T3, T4)> for F
where F: FnOnce(T1, T2, T3, T4) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static, T3: FromRequestParts + 'static, T4: FromRequestParts + 'static,

Source§

impl<F, Fut, Res, T1, T2, T3, T4, B> Handler<WithBody<(T1, T2, T3, T4), B>> for F
where F: FnOnce(T1, T2, T3, T4, B) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static, T3: FromRequestParts + 'static, T4: FromRequestParts + 'static, B: FromRequest + 'static,

Source§

impl<F, Fut, Res, T1, T2, T3, T4, T5> Handler<(T1, T2, T3, T4, T5)> for F
where F: FnOnce(T1, T2, T3, T4, T5) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static, T3: FromRequestParts + 'static, T4: FromRequestParts + 'static, T5: FromRequestParts + 'static,

Source§

impl<F, Fut, Res, T1, T2, T3, T4, T5, B> Handler<WithBody<(T1, T2, T3, T4, T5), B>> for F
where F: FnOnce(T1, T2, T3, T4, T5, B) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static, T3: FromRequestParts + 'static, T4: FromRequestParts + 'static, T5: FromRequestParts + 'static, B: FromRequest + 'static,

Source§

impl<F, Fut, Res, T1, T2, T3, T4, T5, T6> Handler<(T1, T2, T3, T4, T5, T6)> for F
where F: FnOnce(T1, T2, T3, T4, T5, T6) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static, T3: FromRequestParts + 'static, T4: FromRequestParts + 'static, T5: FromRequestParts + 'static, T6: FromRequestParts + 'static,

Source§

impl<F, Fut, Res, T1, T2, T3, T4, T5, T6, B> Handler<WithBody<(T1, T2, T3, T4, T5, T6), B>> for F
where F: FnOnce(T1, T2, T3, T4, T5, T6, B) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static, T3: FromRequestParts + 'static, T4: FromRequestParts + 'static, T5: FromRequestParts + 'static, T6: FromRequestParts + 'static, B: FromRequest + 'static,

Source§

impl<F, Fut, Res, T1, T2, T3, T4, T5, T6, T7> Handler<(T1, T2, T3, T4, T5, T6, T7)> for F
where F: FnOnce(T1, T2, T3, T4, T5, T6, T7) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static, T3: FromRequestParts + 'static, T4: FromRequestParts + 'static, T5: FromRequestParts + 'static, T6: FromRequestParts + 'static, T7: FromRequestParts + 'static,

Source§

impl<F, Fut, Res, T1, T2, T3, T4, T5, T6, T7, B> Handler<WithBody<(T1, T2, T3, T4, T5, T6, T7), B>> for F
where F: FnOnce(T1, T2, T3, T4, T5, T6, T7, B) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static, T3: FromRequestParts + 'static, T4: FromRequestParts + 'static, T5: FromRequestParts + 'static, T6: FromRequestParts + 'static, T7: FromRequestParts + 'static, B: FromRequest + 'static,

Source§

impl<F, Fut, Res, T1, T2, T3, T4, T5, T6, T7, T8> Handler<(T1, T2, T3, T4, T5, T6, T7, T8)> for F
where F: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts + 'static, T2: FromRequestParts + 'static, T3: FromRequestParts + 'static, T4: FromRequestParts + 'static, T5: FromRequestParts + 'static, T6: FromRequestParts + 'static, T7: FromRequestParts + 'static, T8: FromRequestParts + 'static,