error_rail/traits/mod.rs
1//! Core traits for error handling and composition.
2//!
3//! This module defines the fundamental traits that enable error-rail's composable
4//! error handling patterns:
5//!
6//! - [`ErrorCategory`]: Categorical abstraction for lifting values and handling errors
7//! - [`ErrorOps`]: Operations for error recovery and bidirectional mapping
8//! - [`IntoErrorContext`]: Conversion trait for creating structured error contexts
9//! - [`WithError`]: Abstraction for types that carry remappable error variants
10//!
11//! # Examples
12//!
13//! ```
14//! use error_rail::traits::{ErrorCategory, IntoErrorContext};
15//! use error_rail::{ComposableError, ErrorContext};
16//!
17//! // Using ErrorCategory to lift values
18//! let success: Result<i32, String> = <Result<(), String>>::lift(42);
19//! assert_eq!(success, Ok(42));
20//!
21//! // Using IntoErrorContext for structured contexts
22//! let err = ComposableError::<&str>::new("failed")
23//! .with_context("operation context");
24//! assert_eq!(err.context().len(), 1);
25//! ```
26
27pub mod error_category;
28pub mod error_ops;
29pub mod into_error_context;
30pub mod result_ext;
31pub mod transient;
32pub mod with_error;
33
34pub use error_category::ErrorCategory;
35pub use error_ops::ErrorOps;
36pub use into_error_context::IntoErrorContext;
37pub use result_ext::{BoxedResultExt, ResultExt};
38pub use transient::{TransientError, TransientErrorExt};
39pub use with_error::WithError;