Skip to main content

Label

Derive Macro Label 

Source
#[derive(Label)]
Available on crate feature macros only.
Expand description

Derives Label trait for enums, returning variant names.

For each variant, label() returns the variant name as a static string. This is useful for logging, monitoring, and diagram generation.

§Example

use maiko::Label;

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

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

§Panics

Compilation fails if used on a struct (only enums are supported).