mirror of
https://codeberg.org/icewind/tasmota-mqtt-client.git
synced 2026-06-03 18:24:09 +02:00
clippy fixes, msrv
This commit is contained in:
parent
054b8e277c
commit
3e32333d26
3 changed files with 7 additions and 8 deletions
|
|
@ -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"] }
|
||||||
|
|
|
||||||
10
src/lib.rs
10
src/lib.rs
|
|
@ -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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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>)>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue