ComponentId

Trait ComponentId 

Source
pub trait ComponentId: Copy + Debug {
    // Required method
    fn as_str(&self) -> &'static str;
}
Expand description

Trait for component identifiers

This is the minimal trait needed for error codes. Just implement .as_str().

§Examples

use waddling_errors::ComponentId;

#[derive(Debug, Clone, Copy)]
enum Component {
    Parser,
    Network,
}

impl ComponentId for Component {
    fn as_str(&self) -> &'static str {
        match self {
            Component::Parser => "PARSER",
            Component::Network => "NETWORK",
        }
    }
}

Required Methods§

Source

fn as_str(&self) -> &'static str

Get the component name (e.g., “PARSER”, “CRYPTO”)

Must be uppercase, 2-12 characters.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§