Coverage Report

Created: 2025-11-16 06:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/tower-0.5.2/src/retry/layer.rs
Line
Count
Source
1
use super::Retry;
2
use tower_layer::Layer;
3
4
/// Retry requests based on a policy
5
#[derive(Debug, Clone)]
6
pub struct RetryLayer<P> {
7
    policy: P,
8
}
9
10
impl<P> RetryLayer<P> {
11
    /// Creates a new [`RetryLayer`] from a retry policy.
12
0
    pub const fn new(policy: P) -> Self {
13
0
        RetryLayer { policy }
14
0
    }
15
}
16
17
impl<P, S> Layer<S> for RetryLayer<P>
18
where
19
    P: Clone,
20
{
21
    type Service = Retry<P, S>;
22
23
0
    fn layer(&self, service: S) -> Self::Service {
24
0
        let policy = self.policy.clone();
25
0
        Retry::new(policy, service)
26
0
    }
27
}