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
//! Public types backing the `RateLimiter` progress hook. The CLI
//! installs a closure of type [`ProgressHook`] which the limiter calls
//! before each cooldown / spacing sleep so the user can see a
//! transparent "[INFO] rate-limit ..." line on stderr while the
//! request is gated. Library callers that don't need progress
//! reporting can ignore this module entirely; the hook is opt-in.
use Arc;
use Duration;
/// Which kind of wait the limiter is currently performing. Surfaces in
/// `RateLimitProgress` events so callers can render distinct user-facing
/// messages for the post-block cooldown vs. the inter-request spacing
/// gap.
/// One progress observation for an in-flight rate-limit wait. Emitted
/// once per acquire cycle (the inner sleep is bounded so a long
/// cooldown still yields periodic updates without a separate timer
/// task).
///
/// `total ≈ elapsed + remaining` at the moment of emission, modulo
/// jitter and small clock drift.
/// Optional callback the limiter invokes before each wait sleep so a
/// host (typically the CLI) can render a transparent progress line. The
/// closure must be cheap; it is called while holding no locks but on
/// the hot path of the limiter loop.
pub type ProgressHook = ;