pub trait ComponentIdDocumented: ComponentId {
// Provided methods
fn description(&self) -> Option<&'static str> { ... }
fn examples(&self) -> &'static [&'static str] { ... }
fn tags(&self) -> &'static [&'static str] { ... }
}Expand description
Extended trait for components with documentation metadata
Implement this trait if you want your components to appear in generated documentation. All methods have default implementations, so you only provide what you need.
§Examples
use waddling_errors::{ComponentId, ComponentIdDocumented};
#[derive(Debug, Clone, Copy)]
enum Component {
Parser,
}
impl ComponentId for Component {
fn as_str(&self) -> &'static str {
match self {
Component::Parser => "PARSER",
}
}
}
impl ComponentIdDocumented for Component {
fn description(&self) -> Option<&'static str> {
Some(match self {
Component::Parser => "Syntax parsing and tokenization",
})
}
fn tags(&self) -> &'static [&'static str] {
match self {
Component::Parser => &["frontend", "syntax"],
}
}
}Provided Methods§
Sourcefn description(&self) -> Option<&'static str>
fn description(&self) -> Option<&'static str>
Human-readable description of this component
Example: “Parsing phase errors and syntax validation”
Sourcefn examples(&self) -> &'static [&'static str]
fn examples(&self) -> &'static [&'static str]
Example error codes from this component
Example: &["E.PARSER.SYNTAX.001", "W.PARSER.STYLE.010"]
Categories/tags for organization
Example: &["frontend", "compile-time"]
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.