aboutsummaryrefslogtreecommitdiff
path: root/src/services/ping.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2024-06-13 16:54:35 +0200
committerfxqnlr <[email protected]>2024-06-13 16:54:35 +0200
commitc124f9fff690a42ea5fb490e4c7e512ba8448951 (patch)
treef17edd2042d2dc713f3dd6b0bdabbbb2444fc863 /src/services/ping.rs
parent04cd0aee6d000073e49b80a530a40cdb176f7f10 (diff)
downloadwebol-c124f9fff690a42ea5fb490e4c7e512ba8448951.tar
webol-c124f9fff690a42ea5fb490e4c7e512ba8448951.tar.gz
webol-c124f9fff690a42ea5fb490e4c7e512ba8448951.zip
cargo update + `time` update, fix for `Instant` deprecation
Diffstat (limited to 'src/services/ping.rs')
-rw-r--r--src/services/ping.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/services/ping.rs b/src/services/ping.rs
index 4e0ffcf..69c911f 100644
--- a/src/services/ping.rs
+++ b/src/services/ping.rs
@@ -2,8 +2,8 @@ use crate::config::Config;
2use crate::storage::Device; 2use crate::storage::Device;
3use dashmap::DashMap; 3use dashmap::DashMap;
4use ipnetwork::IpNetwork; 4use ipnetwork::IpNetwork;
5use std::fmt::Display; 5use std::{fmt::Display, time::Instant};
6use time::{Duration, Instant}; 6use time::Duration;
7use tokio::sync::broadcast::Sender; 7use tokio::sync::broadcast::Sender;
8use tracing::{debug, error, trace}; 8use tracing::{debug, error, trace};
9 9
@@ -12,7 +12,7 @@ pub type StatusMap = DashMap<String, Value>;
12#[derive(Debug, Clone)] 12#[derive(Debug, Clone)]
13pub struct Value { 13pub struct Value {
14 pub ip: IpNetwork, 14 pub ip: IpNetwork,
15 pub eta: i64, 15 pub eta: u64,
16 pub online: bool, 16 pub online: bool,
17} 17}
18 18
@@ -56,12 +56,12 @@ pub async fn spawn(
56 56
57 let _ = tx.send(msg.clone()); 57 let _ = tx.send(msg.clone());
58 if msg.command == BroadcastCommands::Success { 58 if msg.command == BroadcastCommands::Success {
59 if timer.elapsed().whole_seconds() > config.pingthreshold { 59 if timer.elapsed().as_secs() > config.pingthreshold {
60 let newtimes = if let Some(mut oldtimes) = device.times { 60 let newtimes = if let Some(mut oldtimes) = device.times {
61 oldtimes.push(timer.elapsed().whole_seconds()); 61 oldtimes.push(timer.elapsed().as_secs());
62 oldtimes 62 oldtimes
63 } else { 63 } else {
64 vec![timer.elapsed().whole_seconds()] 64 vec![timer.elapsed().as_secs()]
65 }; 65 };
66 66
67 let updatedev = Device { 67 let updatedev = Device {