error_rail/async_ext/
mod.rs

1//! Async extensions for error-rail.
2//!
3//! This module provides async-aware error handling utilities that maintain
4//! the same lazy evaluation philosophy as the sync counterparts.
5//!
6//! # Feature Flag
7//!
8//! Requires the `async` feature to be enabled:
9//!
10//! ```toml
11//! [dependencies]
12//! error-rail = { version = "0.8", features = ["async"] }
13//! ```
14//!
15//! # Examples
16//!
17//! ```rust,no_run
18//! use error_rail::prelude_async::*;
19//!
20//! #[derive(Debug)]
21//! struct User;
22//!
23//! #[derive(Debug)]
24//! struct ApiError;
25//!
26//! async fn fetch_from_db(_id: u64) -> Result<User, ApiError> {
27//!     Err(ApiError)
28//! }
29//!
30//! async fn fetch_user(id: u64) -> BoxedResult<User, ApiError> {
31//!     fetch_from_db(id)
32//!         .ctx("fetching user from database")
33//!         .await
34//!         .map_err(Box::new)
35//! }
36//! ```
37
38mod context_future;
39mod future_ext;
40mod pipeline;
41
42#[cfg(feature = "async")]
43mod retry;
44
45#[cfg(feature = "async")]
46mod validation;
47
48#[cfg(feature = "tokio")]
49mod tokio_ext;
50
51#[cfg(feature = "tracing")]
52mod tracing_ext;
53
54pub use context_future::ContextFuture;
55pub use future_ext::FutureResultExt;
56pub use pipeline::AsyncErrorPipeline;
57
58#[cfg(feature = "async")]
59pub use retry::{
60    retry_with_metadata, retry_with_policy, ExponentialBackoff, FixedDelay, RetryPolicy,
61    RetryResult,
62};
63
64#[cfg(feature = "async")]
65pub use validation::{validate_all_async, validate_seq_async};
66
67#[cfg(feature = "tokio")]
68pub use tokio_ext::{
69    retry_transient, retry_transient_n, retry_transient_unboxed, try_with_timeout, TimeoutError,
70    TimeoutResult,
71};
72
73#[cfg(feature = "tracing")]
74pub use tracing_ext::{instrument_error, FutureSpanExt, ResultSpanExt, SpanContextFuture};