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
use ;
// mod bucket;
// mod fixed_bucket;
///
///
/// fixed bucket
///
/// ```
/// let b = FixedBucket::new(600, 10).bucket(90, 10.0)
/// ```
///
/// ```
/// b.allow(unique value) // boolean
/// ```
// pub struct TokenBucket {
// capacity: u64,
// rates: f64,
// last_update: HashMap<String, (f64, Instant)>,
// }
// pub struct FixedBucket {
// request: u64,
// duration: Duration,
// capacity: u64,
// rates: f64,
// last_update: HashMap<String, (f64, Instant)>,
// requests: HashMap<String, (u64, Instant)>,
// }