feat: replace std::time with web_time for wasm32-unknown-unknown compatibility #239
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request updates the
reqwest-retry
crate to replace the usage ofstd::time
with theweb-time
crate for handling time-related functionality. This change ensures compatibility with WebAssembly (WASM) environments, wherestd::time
is not supported. The modifications span dependency updates, source code adjustments, and test updates.Dependency Update:
reqwest-retry/Cargo.toml
: Addedweb-time = "1.1.0"
as a dependency to replacestd::time
.Code Changes:
reqwest-retry/src/middleware.rs
: Replaced imports ofstd::time::{Duration, SystemTime}
withweb_time::{Duration, SystemTime}
across the middleware implementation.macro_rules! log_retry
inreqwest-retry/src/middleware.rs
: Updated example code comments to useweb_time::Duration
instead ofstd::time::Duration
.Test Updates:
reqwest-retry/tests/all/retry.rs
:std::time::Duration
withweb_time::Duration
in multiple test functions (assert_retry_succeeds_inner
,assert_retry_on_request_timeout
,assert_retry_on_incomplete_message
,assert_retry_on_hyper_canceled
,assert_retry_on_connection_reset_by_peer
). This ensures compatibility with the new dependency. [1] [2] [3] [4] [5] [6] [7]RetryTimeoutResponder
struct and itsnew
method to useweb_time::Duration
instead ofstd::time::Duration
.It works on my machine
I have already tested that this fix works on my project, by refering git url and rev hash directly.
https://github.com/Dicklessgreat/reqwest-middleware/tree/refer-my-retry-policies
Draft
This PR is draft till the underlying PR is merged TrueLayer/retry-policies#29