#[derive(RecordKey)]
{
// Attributes available to this derive:
#[key]
#[key_prefix]
#[link_address]
}
Expand description
Derive the RecordKey trait for an enum
Each variant must have a #[key = "..."] attribute specifying its string key.
Optionally, the enum can have a #[key_prefix = "..."] attribute to prepend
a common prefix to all keys.
§Connector Metadata
Variants can have a #[link_address = "..."] attribute to associate a connector
URL/address with the key (MQTT topics, KNX group addresses, etc.):
§Example
ⓘ
// Note: Hash is auto-generated to satisfy the Borrow<str> contract
#[derive(RecordKey, Clone, Copy, PartialEq, Eq)]
#[key_prefix = "sensors."]
pub enum SensorKey {
#[key = "temp"] // → "sensors.temp"
#[link_address = "mqtt://sensors/temp/indoor"]
Temperature,
#[key = "humid"] // → "sensors.humid"
#[link_address = "knx://9/0/1"]
Humidity,
}§Generated Code
The macro generates:
impl aimdb_core::RecordKey for YourEnumwithas_str()andlink_address()methodsimpl core::borrow::Borrow<str> for YourEnumfor O(1) HashMap lookupsimpl core::hash::Hash for YourEnumthat hashes the string key (required by Borrow contract)