Function backoff::retry[][src]

pub fn retry<F, B, T, E>(backoff: B, op: F) -> Result<T, Error<E>> where
    F: FnMut() -> Result<T, Error<E>>,
    B: Backoff

Retries this operation according to the backoff policy. backoff is reset before it is used.

Examples

let f = || -> Result<(), Error<&str>> {
    // Business logic...
    // Give up.
    Err(Error::Permanent("error"))
};

let backoff = ExponentialBackoff::default();
let _ = retry(backoff, f).err().unwrap();