Skip to main content

Label

Trait Label 

Source
pub trait Label {
    // Required method
    fn label(&self) -> Cow<'static, str>;
}
Expand description

Human-readable label for an event variant.

Used by the test harness for event matching (e.g. chain.events().contains("KeyPress")), Mermaid diagram generation, and the Recorder monitor for JSON output.

Derive it automatically with #[derive(Label)] (requires the macros feature).

§Example

use maiko::Label;

#[derive(Label)]
enum MyTopic {
    SensorData,
    Alerts,
}

assert_eq!(MyTopic::SensorData.label(), "SensorData");
assert_eq!(MyTopic::Alerts.label(), "Alerts");

Required Methods§

Source

fn label(&self) -> Cow<'static, str>

Returns a human-readable label for this item.

Implementors§