Skip to main content

PrimaryIdDocumented

Trait PrimaryIdDocumented 

Source
pub trait PrimaryIdDocumented: PrimaryId {
    // Provided methods
    fn description(&self) -> Option<&'static str> { ... }
    fn examples(&self) -> &'static [&'static str] { ... }
    fn related(&self) -> &'static [&'static str] { ... }
}
Expand description

Extended trait for primaries with documentation metadata

Implement this trait if you want your primary categories to appear in generated documentation with rich metadata.

§Examples

use waddling_errors::{PrimaryId, PrimaryIdDocumented};

#[derive(Debug, Clone, Copy)]
enum Primary {
    Syntax,
}

impl PrimaryId for Primary {
    fn as_str(&self) -> &'static str {
        match self {
            Primary::Syntax => "SYNTAX",
        }
    }
}

impl PrimaryIdDocumented for Primary {
    fn description(&self) -> Option<&'static str> {
        Some("Syntax-level parsing errors")
    }
}

Provided Methods§

Source

fn description(&self) -> Option<&'static str>

Human-readable description of this primary category

Source

fn examples(&self) -> &'static [&'static str]

Example error codes using this primary

Source

fn related(&self) -> &'static [&'static str]

Related primary categories

Example: SYNTAX relates to PARSE, TOKENIZE

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§