clippy fixes, msrv

This commit is contained in:
Robin Appelman 2024-01-26 23:14:10 +01:00
commit 3e32333d26
3 changed files with 7 additions and 8 deletions

View file

@ -3,7 +3,7 @@ name = "tasmota-mqtt-client"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
rust-version = "1.64.0" rust-version = "1.70.0"
[dependencies] [dependencies]
rumqttc = { version = "0.23.0", features = ["use-rustls"] } rumqttc = { version = "0.23.0", features = ["use-rustls"] }

View file

@ -64,7 +64,7 @@ impl TasmotaClient {
let _ = tx.send(DeviceUpdate::Added(device.into())); let _ = tx.send(DeviceUpdate::Added(device.into()));
} }
"Offline" => { "Offline" => {
edit_devices.lock().unwrap().remove(device.into()); edit_devices.lock().unwrap().remove(device);
let _ = tx.send(DeviceUpdate::Removed(device.into())); let _ = tx.send(DeviceUpdate::Removed(device.into()));
} }
_ => {} _ => {}
@ -103,15 +103,13 @@ impl TasmotaClient {
} }
/// Subscribe to device discovery, receiving a [`DeviceUpdate`] whenever a device comes online or goes offline /// Subscribe to device discovery, receiving a [`DeviceUpdate`] whenever a device comes online or goes offline
///
/// This will include an update for any device that is known at the time of calling
pub fn devices(&self) -> impl Stream<Item = DeviceUpdate> { pub fn devices(&self) -> impl Stream<Item = DeviceUpdate> {
let current = self.current_devices(); let current = self.current_devices();
let rx = self.device_update.subscribe(); let rx = self.device_update.subscribe();
tokio_stream::iter( tokio_stream::iter(current.into_iter().map(DeviceUpdate::Added))
current
.into_iter()
.map(|device| DeviceUpdate::Added(device)),
)
.chain(BroadcastStream::new(rx).filter_map(Result::ok)) .chain(BroadcastStream::new(rx).filter_map(Result::ok))
} }

View file

@ -12,6 +12,7 @@ use tracing::{debug, error};
pub struct MqttHelper { pub struct MqttHelper {
client: AsyncClient, client: AsyncClient,
#[allow(clippy::type_complexity)]
listeners: Arc<Mutex<Vec<(String, Sender<Publish>)>>>, listeners: Arc<Mutex<Vec<(String, Sender<Publish>)>>>,
} }