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. The provider stays typed end-to-end: it is
fused into the link’s SerializedSource at registration time and
called with &T while the value is in hand.
§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))
}
}Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".