Skip to main content

BlanketLayer

Trait BlanketLayer 

Source
pub trait BlanketLayer: Send + Sync {
    // Required method
    fn apply<M, C, S, H>(&self, handler: H) -> impl Handler<M, C, S> + 'static
       where M: Send + Sync + 'static,
             C: Send + 'static,
             S: Send + Sync + 'static,
             H: Handler<M, C, S> + 'static;
}
Expand description

A Layer that wraps a handler on any message type, not one fixed H.

Layer is checked per concrete handler (L: Layer<H>). That bound cannot be discharged when the handler types are hidden, which is exactly the case for a Router mounted through include_router: its handlers are erased behind RouterDef. BlanketLayer carries the wrapping as a generic method, so a layer that applies uniformly (logging, metrics) can wrap every router handler from one bound.

Implemented for Identity, a Stack of blanket layers, and the bundled TracingLayer. Implement it for a custom layer to let the app’s global stack reach router handlers; a layer that only wraps specific handler types cannot be blanket.

Required Methods§

Source

fn apply<M, C, S, H>(&self, handler: H) -> impl Handler<M, C, S> + 'static
where M: Send + Sync + 'static, C: Send + 'static, S: Send + Sync + 'static, H: Handler<M, C, S> + 'static,

Wraps handler, returning the layered handler. S is the app’s shared-state type, threaded so a blanket layer wraps a router handler without fixing its state type.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl BlanketLayer for Identity

Source§

impl BlanketLayer for TracingLayer

Source§

impl<Inner, Outer> BlanketLayer for Stack<Inner, Outer>
where Inner: BlanketLayer, Outer: BlanketLayer,