pub trait TopicProvider<T>: Send + Sync {
// Required method
fn topic(&self, value: &T) -> Option<String>;
}Expand description
Trait for dynamic topic providers (outbound only)
Implement this trait to dynamically determine MQTT topics (or KNX group addresses) based on the data being published. This enables reusable routing logic that can be shared across multiple record types.
§Type Safety
The trait is generic over T, providing compile-time type safety
at the implementation site. Type erasure occurs only at storage time.
§no_std Compatibility
Works in both std and no_std + alloc environments.
§Example
ⓘ
use aimdb_core::connector::TopicProvider;
struct SensorTopicProvider;
impl TopicProvider<Temperature> for SensorTopicProvider {
fn topic(&self, value: &Temperature) -> Option<String> {
Some(format!("sensors/temp/{}", value.sensor_id))
}
}