Trait Handler

Source
pub trait Handler<Input>:
    Send
    + Sync
    + 'static {
    type Output;

    // Required method
    fn call<'life0, 'async_trait>(
        &'life0 self,
        input: Input,
    ) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A simplified asynchronous interface for handling input and output.

Composable request handlers.

Required Associated Types§

Source

type Output

The returned type after the call operator is used.

Required Methods§

Source

fn call<'life0, 'async_trait>( &'life0 self, input: Input, ) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Performs the call operation.

Implementors§

Source§

impl<F, I, Fut, O> Handler<I> for F
where I: Send + 'static, F: Fn(I) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = O> + Send,

Source§

type Output = <Fut as Future>::Output

Source§

impl<H, F, I, O> Handler<I> for After<H, F>
where I: Send + 'static, H: Handler<I, Output = Result<O>>, F: Handler<H::Output, Output = H::Output>,

Source§

type Output = <F as Handler<<H as Handler<I>>::Output>>::Output

Source§

impl<H, F, I, O> Handler<I> for AndThen<H, F>
where I: Send + 'static, H: Handler<I, Output = Result<O>>, F: Handler<O, Output = H::Output>, O: Send,

Source§

type Output = <F as Handler<O>>::Output

Source§

impl<H, F, I, O> Handler<I> for Around<H, F>
where I: Send + 'static, H: Handler<I, Output = Result<O>> + Clone, F: Handler<Next<I, H>, Output = H::Output>,

Source§

impl<H, F, I, O> Handler<I> for Before<H, F>
where I: Send + 'static, F: Handler<I, Output = Result<I>>, H: Handler<I, Output = Result<O>>,

Source§

type Output = <H as Handler<I>>::Output

Source§

impl<H, F, I, O> Handler<I> for OrElse<H, F>
where I: Send + 'static, H: Handler<I, Output = Result<O>>, F: Handler<Error, Output = H::Output>, O: Send,

Source§

impl<H, F, I, O, E> Handler<I> for MapErr<H, F>
where I: Send + 'static, H: Handler<I, Output = Result<O, E>>, F: FnOnce(E) -> Error + Send + Sync + Copy + 'static,

Source§

impl<H, F, I, O, R> Handler<I> for CatchUnwind<H, F>
where I: Send + 'static, H: Handler<I, Output = Result<O>>, O: IntoResponse + Send, F: Handler<Box<dyn Any + Send>, Output = R>, R: IntoResponse,

Source§

impl<H, F, I, O, T> Handler<I> for Map<H, F>
where I: Send + 'static, H: Handler<I, Output = Result<O>>, F: FnOnce(O) -> T + Send + Sync + Copy + 'static,

Source§

impl<H, I, O> Handler<I> for MapInToResponse<H>
where I: Send + 'static, H: Handler<I, Output = Result<O>>, O: IntoResponse,

Source§

impl<H, I, O, F, E, R> Handler<I> for CatchError<H, F, E, R>
where I: Send + 'static, H: Handler<I, Output = Result<O>>, O: IntoResponse + Send, E: Error + Send + 'static, F: Handler<E, Output = R>, R: IntoResponse + 'static,

Source§

impl<H, O> Handler<Request<Body>> for CompressionMiddleware<H>
where H: Handler<Request, Output = Result<O>>, O: IntoResponse,

Available on crate feature compression only.
Source§

impl<H, O> Handler<Request<Body>> for CookieMiddleware<H>
where H: Handler<Request, Output = Result<O>>, O: IntoResponse,

Available on crate feature cookie only.
Source§

impl<H, O> Handler<Request<Body>> for CorsMiddleware<H>
where H: Handler<Request, Output = Result<O>>, O: IntoResponse,

Available on crate feature cors only.
Source§

impl<H, O> Handler<Request<Body>> for LimitsMiddleware<H>
where H: Handler<Request, Output = Result<O>>, O: IntoResponse,

Available on crate feature limits only.
Source§

impl<H, O> Handler<Request<Body>> for MetricsMiddleware<H>
where H: Handler<Request, Output = Result<O>>, O: IntoResponse,

Available on crate features params and otel and otel-metrics only.
Source§

impl<H, O, S, G, V> Handler<Request<Body>> for CsrfMiddleware<H, S, G, V>
where H: Handler<Request, Output = Result<O>>, O: IntoResponse, S: Fn() -> Result<Vec<u8>> + Send + Sync + 'static, G: Fn(&[u8], Vec<u8>) -> Vec<u8> + Send + Sync + 'static, V: Fn(&[u8], String) -> bool + Send + Sync + 'static,

Available on crate feature csrf only.
Source§

impl<H, O, S, G, V> Handler<Request<Body>> for SessionMiddleware<H, S, G, V>
where H: Handler<Request, Output = Result<O>>, O: IntoResponse, S: Storage + 'static, G: Fn() -> String + Send + Sync + 'static, V: Fn(&str) -> bool + Send + Sync + 'static,

Available on crate feature session only.
Source§

impl<H, O, T> Handler<Request<Body>> for TracingMiddleware<H, T>
where H: Handler<Request, Output = Result<O>>, O: IntoResponse, T: TracerProvider + Send + Sync + Clone + 'static, T::Tracer: Tracer + Send + Sync + 'static, <T::Tracer as Tracer>::Span: Span + Send + Sync + 'static,

Available on crate features params and otel and otel-tracing only.
Source§

impl<I, H, E, O> Handler<I> for FnExtHandler<H, E, O>
where I: Send + 'static, E: FromRequest + 'static, E::Error: IntoResponse, H: FnExt<I, E, Output = Result<O>>, O: 'static,

Source§

type Output = <H as FnExt<I, E>>::Output

Source§

impl<I, O> Handler<I> for BoxHandler<I, O>
where I: Send + 'static, O: 'static,

Source§

impl<I, O, S> Handler<Request<I>> for ServiceHandler<S>
where I: HttpBody + Send + 'static, O: HttpBody + Send + 'static, O::Data: Into<Bytes>, O::Error: Into<BoxError>, S: Service<Request<I>, Response = Response<O>> + Send + Sync + 'static, S::Future: Send, S::Error: Into<BoxError>,

Source§

impl<L, R, I, O> Handler<I> for Either<L, R>
where I: Send + 'static, L: Handler<I, Output = O>, R: Handler<I, Output = O>,

Source§

impl<T, H, O> Handler<Request<Body>> for State<(T, H)>
where T: Clone + Send + Sync + 'static, H: Handler<Request, Output = Result<O>>, O: IntoResponse,

Available on crate feature state only.