pub trait Retryable<B, T, E, Fut, FutureFn>{
// Required method
fn retry(
self,
builder: B,
) -> Retry<<B as BackoffBuilder>::Backoff, T, E, Fut, FutureFn> ⓘ;
}Expand description
Retryable will add retry support for functions that produce futures with results.
This means all types that implement FnMut() -> impl Future<Output = Result<T, E>>
will be able to use retry.
For example:
- Functions without extra args:
ⓘ
async fn fetch() -> Result<String> {
Ok(reqwest::get("https://www.rust-lang.org").await?.text().await?)
}- Closures
ⓘ
|| async {
let x = reqwest::get("https://www.rust-lang.org")
.await?
.text()
.await?;
Err(anyhow::anyhow!(x))
}