pub trait BlockingRetryable<B, T, E, F>{
// Required method
fn retry(
self,
builder: &B
) -> BlockingRetry<<B as BackoffBuilder>::Backoff, T, E, F>;
}Expand description
BlockingRetryable will add retry support for 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 as BackoffBuilder>::Backoff, T, E, F>
fn retry( self, builder: &B ) -> BlockingRetry<<B as BackoffBuilder>::Backoff, T, E, F>
Generate a new retry