try-again 0.2.2

Retry synchronous and asynchronous operations.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::tracked_iterator::FiniteIterator;
use std::fmt::Debug;

/// We only implement `DelayStrategy` for any delay-yielding `FiniteIterator` by default.
/// A `FiniteIterator` is enforced, as we want users to always specify a concrete number of retries!
pub trait DelayStrategy<Delay>: Debug {
    fn next_delay(&mut self) -> Option<Delay>;
}

impl<Delay, I> DelayStrategy<Delay> for FiniteIterator<I>
where
    I: Iterator<Item = Delay> + Debug,
{
    fn next_delay(&mut self) -> Option<Delay> {
        self.next()
    }
}