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
use ;
/// A mechanism that specifies how much a request should be throttled.
///
/// Note that using such a mechanism might not guarantee that there will never by slow-down
/// requests, as for example the clocks on the client and server may run differently.
///
/// # Example
///
/// A very dump example specifying that every request should wait one second:
///
///
/// ```rust
/// # use std::error::Error;
/// # use std::time::{Duration, Instant};
/// # use rrw::throttle::ThrottleMechanism;
/// struct OneSecondThrottle {}
///
/// impl ThrottleMechanism for OneSecondThrottle {
/// fn timeout_delay(&mut self, _now: Instant) -> Duration {
/// Duration::from_secs(1)
/// }
/// }
///
/// #
/// # fn main() -> Result<(), Box<dyn Error>> {
/// # Ok(())
/// # }
/// ```