use crate::clock::Timestamp;
#[allow(dead_code)]
pub(crate) trait QuotaTracker: Send + Sync {
fn check(&self, amount: u64, now: Timestamp) -> bool;
fn record(&self, amount: u64, now: Timestamp);
fn remaining(&self, now: Timestamp) -> u64;
fn capacity(&self) -> u64;
fn usage_ratio(&self, now: Timestamp) -> f64 {
let cap = self.capacity();
if cap == 0 {
return 1.0;
}
let rem = self.remaining(now);
1.0 - (rem as f64 / cap as f64)
}
fn burn_rate(&self, now: Timestamp) -> f64;
fn predicted_exhaustion_secs(&self, now: Timestamp) -> f64 {
let rate = self.burn_rate(now);
if rate <= 0.0 {
return f64::INFINITY;
}
let rem = self.remaining(now);
rem as f64 / rate
}
fn reset(&self, now: Timestamp);
}