Replaced impl_cast with a new and improved trait
With this trait the impl_cast macros are no longer needed, simplifying everything. This commit also improved how the actual casting itself is handled.
This commit is contained in:
parent
3689a52afd
commit
f50bc4bd0c
|
@ -142,10 +142,8 @@ impl DeviceManager {
|
||||||
|
|
||||||
debug!(id, "Adding device");
|
debug!(id, "Adding device");
|
||||||
|
|
||||||
{
|
|
||||||
// If the device listens to mqtt, subscribe to the topics
|
// If the device listens to mqtt, subscribe to the topics
|
||||||
let device: Option<&dyn OnMqtt> = device.as_ref().cast();
|
if let Some(device) = device.as_ref().cast() as Option<&dyn OnMqtt> {
|
||||||
if let Some(device) = device {
|
|
||||||
for topic in device.topics() {
|
for topic in device.topics() {
|
||||||
trace!(id, topic, "Subscribing to topic");
|
trace!(id, topic, "Subscribing to topic");
|
||||||
if let Err(err) = self.client.subscribe(topic, QoS::AtLeastOnce).await {
|
if let Err(err) = self.client.subscribe(topic, QoS::AtLeastOnce).await {
|
||||||
|
@ -155,7 +153,6 @@ impl DeviceManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Wrap the device
|
// Wrap the device
|
||||||
let device = Arc::new(RwLock::new(device));
|
let device = Arc::new(RwLock::new(device));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user