rusty_rl/lib.rs
1use std::{
2 collections::HashMap,
3 time::{Duration, Instant},
4};
5// mod bucket;
6mod fixed;
7// mod fixed_bucket;
8
9///
10///
11
12/// fixed bucket
13///
14/// ```
15/// let b = FixedBucket::new(600, 10).bucket(90, 10.0)
16/// ```
17///
18/// ```
19/// b.allow(unique value) // boolean
20/// ```
21
22#[derive(Clone)]
23pub struct FixedLimit {
24 maximum_request: usize,
25 duration: Duration,
26 requests: HashMap<String, (usize, Instant)>,
27}
28
29pub struct Selfb {
30 pub remaning_count: u64,
31 pub is_allowed: bool,
32 pub route: String,
33}
34
35// pub struct TokenBucket {
36// capacity: u64,
37// rates: f64,
38// last_update: HashMap<String, (f64, Instant)>,
39// }
40
41// pub struct FixedBucket {
42// request: u64,
43// duration: Duration,
44// capacity: u64,
45// rates: f64,
46// last_update: HashMap<String, (f64, Instant)>,
47// requests: HashMap<String, (u64, Instant)>,
48// }