Function backoff::future::retry [−][src]
pub fn retry<I, E, Fn, Fut, B>(
backoff: B,
operation: Fn
) -> Retry<impl Sleeper, B, NoopNotify, Fn, Fut>ⓘ 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();