diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-25 11:31:17 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-25 11:32:02 +0100 |
commit | f04dca42e798dc8aaeb9746c7a51aa251c031c72 (patch) | |
tree | c7493c9d6faaf1129cbef45f99012010b564b9f9 | |
parent | 13206cc05afb0aebaef3b6c3aeab7debac47d063 (diff) |
saturatingly convert between actual duration and elapsed time millis
-rw-r--r-- | src/error.rs | 4 | ||||
-rw-r--r-- | src/main.rs | 3 |
2 files changed, 3 insertions, 4 deletions
diff --git a/src/error.rs b/src/error.rs index d3ed5d1..ffb57fe 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,4 @@ -use std::{io, net, num, time}; +use std::{io, net, time}; use tokio::sync::watch; @@ -33,8 +33,6 @@ pub enum Error { Io(#[from] io::Error), #[error("system time monotonicity error: {0}")] SystemTime(#[from] time::SystemTimeError), - #[error("can't convert between integer sizes: {0}")] - TryFromInt(#[from] num::TryFromIntError), #[error("can't receive from tokio watch channel: {0}")] WatchRecv(#[from] watch::error::RecvError), diff --git a/src/main.rs b/src/main.rs index 44f9519..6e5973b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -423,7 +423,8 @@ async fn do_send_dhcp6(dhcp6: &mut Dhcp6, sock: &UdpSocket, packet: Packet) -> R let elapsed = Instant::now() .duration_since(dhcp6.xts) .as_millis() - .try_into()?; + .try_into() + .unwrap_or(u16::MAX); match packet { Packet::Solicit => { |