From c124f9fff690a42ea5fb490e4c7e512ba8448951 Mon Sep 17 00:00:00 2001
From: fxqnlr <felixquinn03@gmail.com>
Date: Thu, 13 Jun 2024 16:54:35 +0200
Subject: cargo update + `time` update, fix for `Instant` deprecation

---
 src/config.rs        |  2 +-
 src/routes/start.rs  |  4 ++--
 src/services/ping.rs | 12 ++++++------
 src/storage.rs       |  4 +++-
 4 files changed, 12 insertions(+), 10 deletions(-)

(limited to 'src')

diff --git a/src/config.rs b/src/config.rs
index bfb28be..7c91c08 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -7,7 +7,7 @@ use crate::auth;
 pub struct Config {
     pub serveraddr: String,
     pub pingtimeout: i64,
-    pub pingthreshold: i64,
+    pub pingthreshold: u64,
     pub timeoffset: i8,
     pub auth: Auth,
 }
diff --git a/src/routes/start.rs b/src/routes/start.rs
index 192a54a..0b6b38b 100644
--- a/src/routes/start.rs
+++ b/src/routes/start.rs
@@ -128,14 +128,14 @@ fn setup_ping(state: Arc<crate::AppState>, device: Device) -> String {
     uuid_ret
 }
 
-fn get_eta(times: Option<Vec<i64>>) -> i64 {
+fn get_eta(times: Option<Vec<u64>>) -> u64 {
     let times = if let Some(times) = times {
         times
     } else {
         vec![0]
     };
 
-    times.iter().sum::<i64>() / i64::try_from(times.len()).unwrap()
+    times.iter().sum::<u64>() / u64::try_from(times.len()).unwrap()
 }
 
 #[derive(Deserialize, ToSchema)]
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;
 use crate::storage::Device;
 use dashmap::DashMap;
 use ipnetwork::IpNetwork;
-use std::fmt::Display;
-use time::{Duration, Instant};
+use std::{fmt::Display, time::Instant};
+use time::Duration;
 use tokio::sync::broadcast::Sender;
 use tracing::{debug, error, trace};
 
@@ -12,7 +12,7 @@ pub type StatusMap = DashMap<String, Value>;
 #[derive(Debug, Clone)]
 pub struct Value {
     pub ip: IpNetwork,
-    pub eta: i64,
+    pub eta: u64,
     pub online: bool,
 }
 
@@ -56,12 +56,12 @@ pub async fn spawn(
 
     let _ = tx.send(msg.clone());
     if msg.command == BroadcastCommands::Success {
-        if timer.elapsed().whole_seconds() > config.pingthreshold {
+        if timer.elapsed().as_secs() > config.pingthreshold {
             let newtimes = if let Some(mut oldtimes) = device.times {
-                oldtimes.push(timer.elapsed().whole_seconds());
+                oldtimes.push(timer.elapsed().as_secs());
                 oldtimes
             } else {
-                vec![timer.elapsed().whole_seconds()]
+                vec![timer.elapsed().as_secs()]
             };
 
             let updatedev = Device {
diff --git a/src/storage.rs b/src/storage.rs
index 52c2e60..90ff1b4 100644
--- a/src/storage.rs
+++ b/src/storage.rs
@@ -19,7 +19,7 @@ pub struct Device {
     pub mac: MacAddress,
     pub broadcast_addr: String,
     pub ip: Option<IpNetwork>,
-    pub times: Option<Vec<i64>>,
+    pub times: Option<Vec<u64>>,
 }
 
 impl Device {
@@ -59,6 +59,8 @@ impl Device {
     }
 }
 
+// Dead Code allowed because of use in OpenApi Macro (not really dead code)
+#[allow(dead_code)]
 #[derive(ToSchema)]
 #[schema(as = Device)]
 pub struct DeviceSchema {
-- 
cgit v1.2.3


From 8268b826cc45f5b2bd31b72339cc310789ab22d4 Mon Sep 17 00:00:00 2001
From: fxqnlr <felixquinn03@gmail.com>
Date: Mon, 17 Jun 2024 10:29:29 +0200
Subject: docs

---
 src/routes/start.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/routes/start.rs b/src/routes/start.rs
index 0b6b38b..e9436f1 100644
--- a/src/routes/start.rs
+++ b/src/routes/start.rs
@@ -16,7 +16,7 @@ use uuid::Uuid;
     path = "/start/{id}",
     request_body = Option<SPayload>,
     responses(
-        (status = 200, description = "start the device with the given id", body = [Response])
+        (status = 200, description = "start device with the given id", body = [Response])
     ),
     params(
         ("id" = String, Path, description = "device id")
-- 
cgit v1.2.3