Skip to main content

Handler

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 'life0: 'async_trait,
             Self: '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 'life0: 'async_trait, Self: 'async_trait,

Performs the call operation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Handler<Request<Body>> for viz::handlers::serve::Dir

Source§

impl Handler<Request<Body>> for viz::handlers::serve::File

Source§

impl Handler<Request<Body>> for Prometheus

Source§

impl<E> Handler<Request<Body>> for viz::handlers::embed::Dir<E>
where E: RustEmbed + Send + Sync + 'static,

Source§

impl<E> Handler<Request<Body>> for viz::handlers::embed::File<E>
where E: RustEmbed + Send + Sync + 'static,

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, 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, Error>>, 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, Error>>, F: FnOnce(O) -> T + Send + Sync + Copy + 'static,

Source§

impl<H, F, I, O> Handler<I> for After<H, F>
where I: Send + 'static, H: Handler<I, Output = Result<O, Error>>, F: Handler<<H as Handler<I>>::Output, Output = <H as Handler<I>>::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, Error>>, F: Handler<O, Output = <H as Handler<I>>::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, Error>> + Clone, F: Handler<(I, H), Output = <H as Handler<I>>::Output>,

Source§

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

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, Error>>, F: Handler<Error, Output = <H as Handler<I>>::Output>, O: Send,

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, Error>>, O: IntoResponse + Send, E: Error + Send + 'static, F: Handler<E, Output = R>, R: IntoResponse + 'static,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

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<Body>, Output = Result<O, Error>>, O: IntoResponse,