pub mod exponential;
pub mod infinite;
pub mod linear;
use std::time::Duration;
use crate::error::TooManyAttempts;
pub use exponential::ExponentialRetryStrategy;
pub use infinite::InfiniteRetryStrategy;
pub use linear::LinearRetryStrategy;
pub trait RetryStrategy {
fn check_attempt(&mut self, attempts_before: usize) -> Result<Duration, TooManyAttempts>;
fn retry_early_returned_errors(&self) -> bool;
}
impl<T> RetryStrategy for &mut T
where
T: RetryStrategy,
{
fn check_attempt(&mut self, attempts_before: usize) -> Result<Duration, TooManyAttempts> {
(*self).check_attempt(attempts_before)
}
fn retry_early_returned_errors(&self) -> bool {
(**self).retry_early_returned_errors()
}
}