summaryrefslogtreecommitdiff
path: root/crates/tor-error
diff options
context:
space:
mode:
Diffstat (limited to 'crates/tor-error')
-rw-r--r--crates/tor-error/Cargo.toml3
-rw-r--r--crates/tor-error/src/retriable.rs18
2 files changed, 11 insertions, 10 deletions
diff --git a/crates/tor-error/Cargo.toml b/crates/tor-error/Cargo.toml
index f801dd950..0cf0c73be 100644
--- a/crates/tor-error/Cargo.toml
+++ b/crates/tor-error/Cargo.toml
@@ -32,12 +32,13 @@ derive_more = { version = "2.0.1", features = ["full"] }
futures = { version = "0.3", optional = true }
http = { version = "1.3.1", optional = true }
paste = "1.0.3"
-retry-error = { path = "../retry-error", version = "0.11.0" } # WRONG should be 0.4.3
+retry-error = { path = "../retry-error", version = "0.11.0" } # WRONG should be 0.4.3
static_assertions = { version = "1", optional = true }
strum = { version = "0.28.0", features = ["derive"] }
thiserror = "2"
tracing = { version = "0.1.36", optional = true }
void = "1"
+web-time-compat = { version = "0.1.0", path = "../web-time-compat" }
[dev-dependencies]
anyhow = "1.0.72"
diff --git a/crates/tor-error/src/retriable.rs b/crates/tor-error/src/retriable.rs
index 87fcbdd32..8f77e1091 100644
--- a/crates/tor-error/src/retriable.rs
+++ b/crates/tor-error/src/retriable.rs
@@ -1,11 +1,9 @@
//! Declare the `RetryTime` enumeration and related code.
use derive_more::{From, Into};
-use std::{
- cmp::Ordering,
- time::{Duration, Instant},
-};
+use std::{cmp::Ordering, time::Duration};
use strum::EnumDiscriminants;
+use web_time_compat::Instant;
/// A description of when an operation may be retried.
///
@@ -87,7 +85,7 @@ pub enum RetryTime {
/// The operation can be retried at some particular time in the future.
///
/// The recipient of this this `RetryTime` variant should wait until the
- /// current time (as returned by `Instant::now` or `SleepProvider::now` as
+ /// current time (as returned by `Instant::get` or `SleepProvider::now` as
/// appropriate) is at least this given instant.
///
/// This case is appropriate for when we have a failure condition caused by
@@ -274,13 +272,15 @@ mod test {
#![allow(clippy::useless_vec)]
#![allow(clippy::needless_pass_by_value)]
//! <!-- @@ end test lint list maintained by maint/add_warning @@ -->
+
use super::*;
+ use web_time_compat::InstantExt;
#[test]
fn comparison() {
use RetryTime as RT;
let sec = Duration::from_secs(1);
- let now = Instant::now();
+ let now = Instant::get();
let sorted = vec![
RT::Immediate,
@@ -304,7 +304,7 @@ mod test {
fn abs_comparison() {
use AbsRetryTime as ART;
let sec = Duration::from_secs(1);
- let now = Instant::now();
+ let now = Instant::get();
let sorted = vec![
ART::Immediate,
@@ -324,7 +324,7 @@ mod test {
#[test]
fn earliest_absolute() {
let sec = Duration::from_secs(1);
- let now = Instant::now();
+ let now = Instant::get();
let times = vec![RetryTime::AfterWaiting, RetryTime::Never];
@@ -337,7 +337,7 @@ mod test {
#[test]
fn abs_from_sum() {
- let base = Instant::now();
+ let base = Instant::get();
let delta = Duration::from_secs(1);
assert_eq!(
AbsRetryTime::from_sum(base, delta),