Asynchronous retry strategies based on futures.
Add this to your Cargo.toml
:
[dependencies]
futures-backoff = "0.1"
extern crate futures;
extern crate futures_backoff;
use futures::{Future, future};
use futures_backoff::retry;
fn main() {
let future = retry(|| {
// do some real-world stuff here...
future::ok::<u32, ::std::io::Error>(42)
});
let result = future.wait();
assert_eq!(result, Ok(42));
}