eztry 0.0.1

easy-to-use utilities to add retry logic to async functions
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#[derive(Debug)]
pub enum RetryResult<T, E> {
    Success(T),
    Retry(E), /* Propagated only if all retries exhausted*/
    Abort(E),
}

unsafe impl<T,E> Send for RetryResult<T,E> {}
unsafe impl<T,E> Sync for RetryResult<T,E> {}

impl<T, E> From<RetryResult<T, E>> for Result<T, E> {
    fn from(r: RetryResult<T, E>) -> Self {
        match r {
            RetryResult::Success(t) => Ok(t),
            RetryResult::Abort(e) | RetryResult::Retry(e) => Err(e),
        }
    }
}