Coverage Report

Created: 2026-04-14 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/tower-layer-0.3.3/src/identity.rs
Line
Count
Source
1
use super::Layer;
2
use std::fmt;
3
4
/// A no-op middleware.
5
///
6
/// When wrapping a [`Service`], the [`Identity`] layer returns the provided
7
/// service without modifying it.
8
///
9
/// [`Service`]: https://docs.rs/tower-service/latest/tower_service/trait.Service.html
10
#[derive(Default, Clone)]
11
pub struct Identity {
12
    _p: (),
13
}
14
15
impl Identity {
16
    /// Create a new [`Identity`] value
17
0
    pub const fn new() -> Identity {
18
0
        Identity { _p: () }
19
0
    }
20
}
21
22
/// Decorates a [`Service`], transforming either the request or the response.
23
///
24
/// [`Service`]: https://docs.rs/tower-service/latest/tower_service/trait.Service.html
25
impl<S> Layer<S> for Identity {
26
    type Service = S;
27
28
0
    fn layer(&self, inner: S) -> Self::Service {
29
0
        inner
30
0
    }
31
}
32
33
impl fmt::Debug for Identity {
34
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35
0
        f.debug_struct("Identity").finish()
36
0
    }
37
}