update to iterator api

This commit is contained in:
Robin Appelman 2020-12-12 15:10:54 +01:00
commit 4c573d0d3b
2 changed files with 6 additions and 5 deletions

2
Cargo.lock generated
View file

@ -1057,7 +1057,7 @@ dependencies = [
[[package]]
name = "mitemp"
version = "0.2.0"
source = "git+https://github.com/icewind1991/mitemp-rs#2d673c48fa3751f8248209a3ef10ebdb8673d1ea"
source = "git+https://github.com/icewind1991/mitemp-rs#16cf74d09fe8546a592c3af5bce4a83f7b29af8a"
dependencies = [
"btleplug",
"num_enum",

View file

@ -36,12 +36,13 @@ async fn main() -> Result<(), MainError> {
let adapter = adapter_by_mac(adapter).map_err(|_| "Adapter not found")?;
let rx = listen(adapter).map_err(|e| format!("Failed to start btle listen: {}", e))?;
let iter = listen(adapter).map_err(|e| format!("Failed to start btle listen: {}", e))?;
let rx_cache = cache.clone();
spawn(move || loop {
let sensor = rx.recv().unwrap();
rx_cache.lock().unwrap().insert(sensor.mac, sensor);
spawn(move || {
for sensor in iter {
rx_cache.lock().unwrap().insert(sensor.mac, sensor);
}
});
let metrics = warp::path!("metrics").map(move || {