diff options
Diffstat (limited to 'crates/tor-proto/src/util')
| -rw-r--r-- | crates/tor-proto/src/util/skew.rs | 3 | ||||
| -rw-r--r-- | crates/tor-proto/src/util/token_bucket/bucket.rs | 2 | ||||
| -rw-r--r-- | crates/tor-proto/src/util/token_bucket/writer.rs | 6 | ||||
| -rw-r--r-- | crates/tor-proto/src/util/tunnel_activity.rs | 9 |
4 files changed, 12 insertions, 8 deletions
diff --git a/crates/tor-proto/src/util/skew.rs b/crates/tor-proto/src/util/skew.rs index a75d51e57..6648cda46 100644 --- a/crates/tor-proto/src/util/skew.rs +++ b/crates/tor-proto/src/util/skew.rs @@ -161,10 +161,11 @@ mod test { use super::*; use tor_basic_utils::test_rng::testing_rng; + use web_time_compat::SystemTimeExt; #[test] fn make_skew() { - let now = SystemTime::now(); + let now = SystemTime::get(); let later = now + Duration::from_secs(777); let earlier = now - Duration::from_secs(333); let window = Duration::from_secs(30); diff --git a/crates/tor-proto/src/util/token_bucket/bucket.rs b/crates/tor-proto/src/util/token_bucket/bucket.rs index ff39b1fe6..2e58f5cbe 100644 --- a/crates/tor-proto/src/util/token_bucket/bucket.rs +++ b/crates/tor-proto/src/util/token_bucket/bucket.rs @@ -1,7 +1,7 @@ //! A token bucket implementation. use std::fmt::Debug; -use std::time::{Duration, Instant}; +use web_time_compat::{Duration, Instant}; /// A token bucket. /// diff --git a/crates/tor-proto/src/util/token_bucket/writer.rs b/crates/tor-proto/src/util/token_bucket/writer.rs index 9e5b05ab6..6fd6d3eb5 100644 --- a/crates/tor-proto/src/util/token_bucket/writer.rs +++ b/crates/tor-proto/src/util/token_bucket/writer.rs @@ -4,7 +4,7 @@ use std::future::Future; use std::num::NonZero; use std::pin::Pin; use std::task::{Context, Poll}; -use std::time::{Duration, Instant}; +use web_time_compat::{Duration, Instant}; use futures::AsyncWrite; use futures::io::Error; @@ -26,7 +26,9 @@ pub(crate) struct RateLimitedWriter<W: AsyncWrite, P: SleepProvider> { /// /// While we use [`Instant`] for the time, we should always get the time from this /// [`SleepProvider`]. - /// For example, use [`SleepProvider::now()`], not [`Instant::now()`]. + /// For example, use [`SleepProvider::now()`], + /// not [`Instant::now()`](std::time::Instant::now) or + /// [`InstantExt::get`](web_time_compat::InstantExt::get). #[educe(Debug(ignore))] sleep_provider: P, /// See [`RateLimitedWriterConfig::wake_when_bytes_available`]. diff --git a/crates/tor-proto/src/util/tunnel_activity.rs b/crates/tor-proto/src/util/tunnel_activity.rs index 62307fd0c..a51bb71e4 100644 --- a/crates/tor-proto/src/util/tunnel_activity.rs +++ b/crates/tor-proto/src/util/tunnel_activity.rs @@ -1,7 +1,8 @@ //! Helpers for tracking whether a tunnel or circuit is still active. use derive_deftly::Deftly; -use std::{num::NonZeroUsize, time::Instant}; +use std::num::NonZeroUsize; +use web_time_compat::{Instant, InstantExt}; /// An object to track whether a tunnel or circuit should still be considered active. /// @@ -132,7 +133,7 @@ impl TunnelActivity { *n_open_streams = new_value; } else { self.inner = Inner::Disused { - since: Instant::now(), + since: Instant::get(), }; } } @@ -154,7 +155,7 @@ impl TunnelActivity { /// /// # A note about time /// - /// The returned Instant value is a direct result of an earlier call to `Instant::now()`. + /// The returned Instant value is a direct result of an earlier call to `Instant::get()`. /// It is not affected by any runtime mocking. pub(crate) fn disused_since(&self) -> Option<Instant> { match self.inner { @@ -189,7 +190,7 @@ mod test { #[test] fn ordering() { use Inner::*; - let t1 = Instant::now(); + let t1 = Instant::get(); let t2 = t1 + Duration::new(60, 0); let t3 = t2 + Duration::new(120, 0); let sorted = vec