pub struct RateLimitQuota {
pub max_requests: u32,
pub current_requests: u32,
pub period_seconds: u64,
pub period_start_ms: u64,
}Expand description
Rate limit quota for API requests.
Fields§
§max_requests: u32Maximum requests allowed in period.
current_requests: u32Current request count in period.
period_seconds: u64Period duration in seconds.
period_start_ms: u64Period start timestamp (Unix milliseconds).
Implementations§
Source§impl RateLimitQuota
impl RateLimitQuota
Sourcepub fn new(
max_requests: u32,
current_requests: u32,
period_seconds: u64,
period_start_ms: u64,
) -> Self
pub fn new( max_requests: u32, current_requests: u32, period_seconds: u64, period_start_ms: u64, ) -> Self
Create a new rate limit quota.
Sourcepub fn remaining_requests(&self) -> u32
pub fn remaining_requests(&self) -> u32
Get remaining requests allowed.
Sourcepub fn is_allowed(&self) -> bool
pub fn is_allowed(&self) -> bool
Check if another request is allowed.
Sourcepub fn is_exceeded(&self) -> bool
pub fn is_exceeded(&self) -> bool
Check if rate limit is exceeded.
Sourcepub fn utilization(&self) -> f64
pub fn utilization(&self) -> f64
Get utilization percentage (0.0 to 1.0).
Sourcepub fn is_period_expired(&self, current_time_ms: u64) -> bool
pub fn is_period_expired(&self, current_time_ms: u64) -> bool
Check if period has expired (given current time).
Trait Implementations§
Source§impl Clone for RateLimitQuota
impl Clone for RateLimitQuota
Source§fn clone(&self) -> RateLimitQuota
fn clone(&self) -> RateLimitQuota
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RateLimitQuota
impl Debug for RateLimitQuota
Source§impl Default for RateLimitQuota
impl Default for RateLimitQuota
Source§impl<'de> Deserialize<'de> for RateLimitQuota
impl<'de> Deserialize<'de> for RateLimitQuota
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for RateLimitQuota
impl PartialEq for RateLimitQuota
Source§impl Serialize for RateLimitQuota
impl Serialize for RateLimitQuota
impl StructuralPartialEq for RateLimitQuota
Auto Trait Implementations§
impl Freeze for RateLimitQuota
impl RefUnwindSafe for RateLimitQuota
impl Send for RateLimitQuota
impl Sync for RateLimitQuota
impl Unpin for RateLimitQuota
impl UnwindSafe for RateLimitQuota
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more