Expand description
Record identification types for stable, O(1) lookups
This module provides key types for record identification:
RecordKey: A trait for type-safe record identifiersStringKey: Default string-based key implementationRecordId: An internal index for O(1) hot-path lookups
§Design Rationale
AimDB separates logical identity (RecordKey) from physical identity (RecordId):
-
RecordKey is a trait that can be implemented by user-defined enums for compile-time checked keys, or use the default
StringKeyfor string-based keys. -
RecordId is the hot-path identifier used internally for O(1) Vec indexing during produce/consume operations.
§Examples
§StringKey (default, edge/cloud)
use aimdb_core::record_id::StringKey;
// Static keys (zero allocation, preferred)
let key: StringKey = "sensors.temperature".into();
assert!(key.is_static());
// Dynamic keys (for runtime-generated names)
let tenant_id = "acme";
let key = StringKey::intern(format!("tenant.{}.sensors", tenant_id));
assert!(!key.is_static());§Enum Keys (compile-time safe, embedded)
Illustrative (not compiled: the derive macro lives in aimdb-derive,
behind the optional derive feature):
ⓘ
use aimdb_derive::RecordKey;
#[derive(RecordKey, Clone, Copy, PartialEq, Eq)]
pub enum AppKey {
#[key = "temp.indoor"]
TempIndoor,
#[key = "temp.outdoor"]
TempOutdoor,
}
// Compile-time typo detection!
builder.configure::<Temperature>(AppKey::TempIndoor, |reg| { /* … */ });Structs§
Traits§
- Record
Key - Trait for record key types
Derive Macros§
- Record
Key - Derive the
RecordKeytrait for an enum