Trait MiddlewareLike

Source
pub trait MiddlewareLike<TLayerCtx>: Clone {
    type State: Clone + Send + Sync + 'static;
    type NewCtx: Send + 'static;

    // Required method
    fn handle<TMiddleware: Layer<Self::NewCtx> + 'static>(
        &self,
        ctx: TLayerCtx,
        input: Value,
        req: RequestContext,
        next: Arc<TMiddleware>,
    ) -> Result<LayerResult, ExecError>;
}

Required Associated Types§

Source

type State: Clone + Send + Sync + 'static

Source

type NewCtx: Send + 'static

Required Methods§

Source

fn handle<TMiddleware: Layer<Self::NewCtx> + 'static>( &self, ctx: TLayerCtx, input: Value, req: RequestContext, next: Arc<TMiddleware>, ) -> Result<LayerResult, ExecError>

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<TState, TLayerCtx, TNewCtx, THandlerFunc, THandlerFut> MiddlewareLike<TLayerCtx> for Middleware<TState, TLayerCtx, TNewCtx, THandlerFunc, THandlerFut>
where TState: Clone + Send + Sync + 'static, TLayerCtx: Send, TNewCtx: Send + 'static, THandlerFunc: Fn(MiddlewareContext<TLayerCtx, TLayerCtx, ()>) -> THandlerFut + Clone, THandlerFut: Future<Output = Result<MiddlewareContext<TLayerCtx, TNewCtx, TState>, Error>> + Send + 'static,

Source§

type State = TState

Source§

type NewCtx = TNewCtx

Source§

impl<TState, TLayerCtx, TNewCtx, THandlerFunc, THandlerFut, TRespHandlerFunc, TRespHandlerFut> MiddlewareLike<TLayerCtx> for MiddlewareWithResponseHandler<TState, TLayerCtx, TNewCtx, THandlerFunc, THandlerFut, TRespHandlerFunc, TRespHandlerFut>
where TState: Clone + Send + Sync + 'static, TLayerCtx: Send + 'static, TNewCtx: Send + 'static, THandlerFunc: Fn(MiddlewareContext<TLayerCtx, TLayerCtx, ()>) -> THandlerFut + Clone, THandlerFut: Future<Output = Result<MiddlewareContext<TLayerCtx, TNewCtx, TState>, Error>> + Send + 'static, TRespHandlerFunc: Fn(TState, Value) -> TRespHandlerFut + Clone + Sync + Send + 'static, TRespHandlerFut: Future<Output = Result<Value, Error>> + Send + 'static,

Source§

type State = TState

Source§

type NewCtx = TNewCtx