1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//! # A crate for trying things again.
//! `tryagain` is a crate to try things again if they fail inspired by
//! [backoff](https://docs.rs/backoff) that offers an easier way to cancel
//! retry attemps and uses a non-blocking async implementation.
//! ## Sync example
//! ```
//! # use tryagain::*;
//! fn fails() -> Result<(), i32> {
//! #   return Ok(()); // So our doctests pass.
//!     Err(0)
//! }
//!
//! // Will never resolve into, will spin forever.
//! let value = tryagain::retry(ImmediateBackoff, fails);
//! ```
//! ## Async example
//! ```
//! # use tryagain::*;
//! # async {
//! async fn fails() -> Result<(), i32> {
//! #   return Ok(()); // So our doctests pass.
//!     Err(0)
//! }
//! 
//! // Will never resolve into, will spin forever.
//! let value = tryagain::future::retry(ImmediateBackoff, fails).await;
//! # };
//! ```

#![forbid(unsafe_code)]
#![forbid(missing_docs)]

#[cfg(any(feature = "runtime-tokio", feature = "runtime-async-std"))]
pub mod future;

mod sync;
mod backoff;

pub use backoff::*;
pub use sync::*;