1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Target-neutral async sleep helper and wall clock for retry delays.
use Duration;
use SystemTime;
use Delay;
use TimeoutFuture;
/// Sleeps for the supplied retry delay on the active target.
///
/// # Panics
///
/// Panics only on `wasm32` if the explicitly clamped millisecond duration
/// cannot be represented by the timer API.
pub async
/// Returns the current wall-clock time as a [`std::time::SystemTime`] on the
/// active target.
///
/// Retry-delay computation reads the wall clock to evaluate an absolute
/// `Retry-After` HTTP-date against "now". On native targets this resolves to
/// [`std::time::SystemTime::now`]. On `wasm32-unknown-unknown` the standard
/// `SystemTime::now` is unavailable and panics, so this helper reads the
/// browser wall clock through `web_time::SystemTime` and re-anchors it onto a
/// [`std::time::SystemTime`] via `UNIX_EPOCH` arithmetic (which is available on
/// wasm). The returned value therefore feeds
/// [`crate::transport::policy::RetryPolicy::delay_for_status`] and
/// [`crate::transport::policy::parse_retry_after`] uniformly across targets without a panic path.
/// Returns the current wall-clock time as a [`std::time::SystemTime`] on the
/// active target.
///
/// See the native variant for the full contract. On `wasm32-unknown-unknown`
/// the standard `SystemTime::now` panics, so this reads the browser wall clock
/// through `web_time::SystemTime` and re-anchors the elapsed duration onto a
/// [`std::time::SystemTime`] starting at `UNIX_EPOCH`. A clock reported before
/// the Unix epoch saturates to `UNIX_EPOCH`.