Trait viz_core::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 + ?Sized + Clone + Send + Sync + 'static, Fut: Future<Output = O> + Send,

§

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>,

§

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,

§

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>,

§

type Output = <F as Handler<(I, 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>>,

§

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,

§

type Output = <F as Handler<Error>>::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,

§

type Output = Result<O, Error>

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,

§

type Output = Result<T, Error>

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: Tracer + Send + Sync + Clone + 'static, T::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,

§

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

source§

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

§

type Output = O

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>,

§

type 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.