use tokio::time::Instant;
use super::SimpleRateLimiter;
impl SimpleRateLimiter {
pub fn clean(&self) {
let mut history = self
.history
.lock()
.expect("rate limiter mutex was poisoned");
self.clean_history(&mut history, Instant::now());
}
pub fn len(&self) -> usize {
let mut history = self
.history
.lock()
.expect("rate limiter mutex was poisoned");
self.clean_history(&mut history, Instant::now());
history.len()
}
pub unsafe fn clear(&self) {
let mut history = self
.history
.lock()
.expect("rate limiter mutex was poisoned");
history.clear();
}
}