Function backoff::future::retry[][src]

pub fn retry<I, E, Fn, Fut, B>(
    backoff: B,
    operation: Fn
) -> Retry<impl Sleeper, B, NoopNotify, Fn, Fut>

Notable traits for Retry<S, B, N, Fn, Fut>

impl<S, B, N, Fn, Fut, I, E> Future for Retry<S, B, N, Fn, Fut> where
    S: Sleeper,
    B: Backoff,
    N: Notify<E>,
    Fn: FnMut() -> Fut,
    Fut: Future<Output = Result<I, Error<E>>>, 
type Output = Result<I, E>;
where
    B: Backoff,
    Fn: FnMut() -> Fut,
    Fut: Future<Output = Result<I, Error<E>>>, 
This is supported on crate feature futures only.

Retries given operation according to the Backoff policy Backoff is reset before it is used. The returned future can be spawned onto a compatible runtime.

Only available through the tokio and async-std feature flags.

Example

use backoff::ExponentialBackoff;

async fn f() -> Result<(), backoff::Error<&'static str>> {
    // Business logic...
    Err(backoff::Error::Permanent("error"))
}

backoff::future::retry(ExponentialBackoff::default(), f).await.err().unwrap();