pub trait BlockingRetryable<B: BackoffBuilder, T, E, F: FnMut() -> Result<T, E>> {
// Required method
fn retry(self, builder: B) -> BlockingRetry<B::Backoff, T, E, F>;
}
Expand description
BlockingRetryable adds retry support for blocking functions.
For example:
- Functions without extra args:
ⓘ
fn fetch() -> Result<String> {
Ok("hello, world!".to_string())
}
- Closures
ⓘ
|| {
Ok("hello, world!".to_string())
}
§Example
use anyhow::Result;
use backon::BlockingRetryable;
use backon::ExponentialBuilder;
fn fetch() -> Result<String> {
Ok("hello, world!".to_string())
}
fn main() -> Result<()> {
let content = fetch.retry(ExponentialBuilder::default()).call()?;
println!("fetch succeeded: {}", content);
Ok(())
}
Required Methods§
Sourcefn retry(self, builder: B) -> BlockingRetry<B::Backoff, T, E, F>
fn retry(self, builder: B) -> BlockingRetry<B::Backoff, T, E, F>
Generate a new retry.