1use std::{
2 collections::HashMap,
3 time::{Duration, Instant},
4};
5mod bucket;
6mod fixed;
7mod fixed_bucket;
8
9pub struct FixedLimit {
23 maximum_request: usize,
24 duration: Duration,
25 requests: HashMap<String, (usize, Instant)>,
26}
27
28pub struct Selfb {
29 pub remaning_count: u64,
30 pub is_allowed: bool,
31}
32
33pub struct TokenBucket {
34 capacity: u64,
35 rates: f64,
36 last_update: HashMap<String, (f64, Instant)>,
37}
38
39pub struct FixedBucket {
40 request: u64,
41 duration: Duration,
42 capacity: u64,
43 rates: f64,
44 last_update: HashMap<String, (f64, Instant)>,
45 requests: HashMap<String, (u64, Instant)>,
46}