rusty-rl 0.1.0

simple ratelimit helper
Documentation
use std::{
    collections::HashMap,
    time::{Duration, Instant},
};
mod bucket;
mod fixed;
mod fixed_bucket;

///
///

/// fixed bucket
///
/// ```
///     let b = FixedBucket::new(600, 10).bucket(90, 10.0)
/// ```
///
/// ```
///     b.allow(unique value) // boolean
/// ```

pub struct FixedLimit {
    maximum_request: usize,
    duration: Duration,
    requests: HashMap<String, (usize, Instant)>,
}

pub struct Selfb {
    pub remaning_count: u64,
    pub is_allowed: bool,
}

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)>,
}