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§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".