pub trait TraceableError:
Debug
+ Display
+ 'static {
// Required methods
fn as_any(&self) -> &dyn Any;
fn layer_code(&self) -> String;
fn chain_codes(&self) -> Vec<String>;
// Provided methods
fn diagnostic_code(&self) -> String { ... }
fn source_error(&self) -> Option<&(dyn Error + 'static)> { ... }
}Expand description
Defines an error that can be deterministically traced through a distributed architecture.
Implementations of this trait (typically derived automatically via #[derive(TraceableError)]
on enums) are capable of recursively interrogating their underlying causal chain
and reporting a unified chronological history of layer codes.
Each layer code is represented by a structured String identifier:
format!("{crate_name}::{enum_name}::{variant_name}").
This structured layout facilitates highly readable failure trajectory reconstruction across distributed IPC boundaries and dynamic crate boundaries.
Required Methods§
Sourcefn layer_code(&self) -> String
fn layer_code(&self) -> String
Returns this specific layer’s string identifier (format: CrateName::EnumName::EnumValue).
Sourcefn chain_codes(&self) -> Vec<String>
fn chain_codes(&self) -> Vec<String>
Recursively interrogates underlying error sources to build the chronological array of layer codes.
The resulting vector is ordered from outermost (most recent) layer to innermost (root cause).
Provided Methods§
Sourcefn diagnostic_code(&self) -> String
fn diagnostic_code(&self) -> String
Formats the layer code vector into a standardized diagnostic string (e.g., "Crate1::Enum1::Val1-Crate2::Enum2::Val2").
Sourcefn source_error(&self) -> Option<&(dyn Error + 'static)>
fn source_error(&self) -> Option<&(dyn Error + 'static)>
Returns the underlying causal error, if any, as a dynamic std::error::Error.
If your type also implements std::error::Error, you should override this
to return self.source(). The #[derive(TraceableError)] macro does this automatically.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".