mirror of
https://github.com/tower-rs/tower.git
synced 2025-09-30 14:31:41 +00:00
27 lines
554 B
Rust
27 lines
554 B
Rust
use tower_layer::Layer;
|
|
|
|
/// A no-op middleware.
|
|
///
|
|
/// When wrapping a `Service`, the `Identity` layer returns the provided
|
|
/// service without modifying it.
|
|
#[derive(Debug, Default, Clone)]
|
|
pub struct Identity {
|
|
_p: (),
|
|
}
|
|
|
|
impl Identity {
|
|
/// Create a new `Identity` value
|
|
pub fn new() -> Identity {
|
|
Identity { _p: () }
|
|
}
|
|
}
|
|
|
|
/// Decorates a `Service`, transforming either the request or the response.
|
|
impl<S> Layer<S> for Identity {
|
|
type Service = S;
|
|
|
|
fn layer(&self, inner: S) -> Self::Service {
|
|
inner
|
|
}
|
|
}
|