maiko/label.rs
1use std::borrow::Cow;
2
3/// Human-readable label for an event variant.
4///
5/// Used by the test harness for event matching (e.g. `chain.events().contains("KeyPress")`),
6/// Mermaid diagram generation, and the `Recorder` monitor for JSON output.
7///
8/// Derive it automatically with `#[derive(Label)]` (requires the `macros` feature).
9///
10/// # Example
11///
12/// ```rust
13/// use maiko::Label;
14///
15/// #[derive(Label)]
16/// enum MyTopic {
17/// SensorData,
18/// Alerts,
19/// }
20///
21/// assert_eq!(MyTopic::SensorData.label(), "SensorData");
22/// assert_eq!(MyTopic::Alerts.label(), "Alerts");
23/// ```
24pub trait Label {
25 /// Returns a human-readable label for this item.
26 fn label(&self) -> Cow<'static, str>;
27}