use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct RateLimit {
pub bucket: Option<String>,
pub limit: u32,
pub remaining: u32,
pub reset: u64,
pub retry_after: Option<u64>,
}
impl RateLimit {
pub fn is_exceeded(&self) -> bool {
self.remaining == 0
}
pub fn reset_in(&self) -> u64 {
let now = chrono::Utc::now().timestamp() as u64;
self.reset.saturating_sub(now)
}
}