[][src]Function tryagain::retry

pub fn retry<B, F, T, E>(backoff: B, func: F) -> T where
    B: Backoff,
    F: Fn() -> Result<T, E>, 

Retries the provided function if it returns an error whenever the backoff allows. The first call resulting in success will have it's value returned to the caller.

Example

// In the real world this would do some computation that returns a result.
fn returns_err() -> Result<(), ()> {
    Err(())
}

// In this example we never get a value, we just spin forever.
let value = retry(ExponentialBackoff::default(), returns_err);