Trait Layer
pub trait Layer<S>: Sized {
type Service;
// Required method
fn layer(&self, inner: S) -> Self::Service;
// Provided method
fn into_layer(self, inner: S) -> Self::Service { ... }
}
Expand description
A layer that produces a Layered service (middleware(inner service)).
Required Associated Types§
type Service
type Service
The service produced by the layer.
Required Methods§
Provided Methods§
fn into_layer(self, inner: S) -> Self::Service
fn into_layer(self, inner: S) -> Self::Service
Same as layer
but consuming self after the service was created.
This is useful in case you no longer need the Layer after the service
is created. By default this calls layer
but if your Layer
impl
requires cloning you can impl this method as well to avoid the cloning
for the cases where you no longer need the data in the Layer
after
service ceation.
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.