Skip to main content

retry_async

Function retry_async 

Source
pub async fn retry_async<F, Fut, T, E>(
    policy: &RetryPolicy,
    f: F,
) -> Result<T, E>
where F: Fn() -> Fut, Fut: Future<Output = Result<T, E>>, E: Display,
Expand description

Executes f up to policy.max_attempts times, sleeping between attempts according to the policy, and returns the first Ok result or the last error.

ยงType Parameters

  • F: An async closure/function that produces a Future.
  • Fut: The Future type returned by f.
  • T: The success type.
  • E: The error type; must implement std::fmt::Display for retryability checks.