retry_future/
retry_strategy.rs1pub mod exponential;
2pub mod infinite;
3pub mod linear;
4
5use std::time::Duration;
6
7use crate::error::TooManyAttempts;
8pub use exponential::ExponentialRetryStrategy;
9pub use infinite::InfiniteRetryStrategy;
10pub use linear::LinearRetryStrategy;
11
12pub trait RetryStrategy {
18 fn check_attempt(&mut self, attempts_before: usize) -> Result<Duration, TooManyAttempts>;
21
22 fn retry_early_returned_errors(&self) -> bool;
25}
26
27impl<T> RetryStrategy for &mut T
28where
29 T: RetryStrategy,
30{
31 fn check_attempt(&mut self, attempts_before: usize) -> Result<Duration, TooManyAttempts> {
32 (*self).check_attempt(attempts_before)
33 }
34
35 fn retry_early_returned_errors(&self) -> bool {
36 (**self).retry_early_returned_errors()
37 }
38}