pub struct RateLimitHeaders {
pub limit: u32,
pub remaining: u32,
pub reset: i64,
pub retry_after: Option<u64>,
}Expand description
Rate limit response headers following RFC 6585 and draft standards.
These headers inform clients about their rate limit status.
Fields§
§limit: u32Maximum requests allowed in the time window
remaining: u32Remaining requests in the current window
reset: i64Unix timestamp when the rate limit window resets
retry_after: Option<u64>Time until reset in seconds (for convenience)
Implementations§
Source§impl RateLimitHeaders
impl RateLimitHeaders
Sourcepub fn exceeded(limit: u32, reset: i64) -> Self
pub fn exceeded(limit: u32, reset: i64) -> Self
Create rate limit headers when limit is exceeded
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 the utilization as a percentage (0.0 to 1.0)
Sourcepub fn as_http_headers(&self) -> Vec<(&'static str, String)>
pub fn as_http_headers(&self) -> Vec<(&'static str, String)>
Format as HTTP header pairs (name, value)
Trait Implementations§
Source§impl Clone for RateLimitHeaders
impl Clone for RateLimitHeaders
Source§fn clone(&self) -> RateLimitHeaders
fn clone(&self) -> RateLimitHeaders
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 RateLimitHeaders
impl Debug for RateLimitHeaders
Source§impl<'de> Deserialize<'de> for RateLimitHeaders
impl<'de> Deserialize<'de> for RateLimitHeaders
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 RateLimitHeaders
impl PartialEq for RateLimitHeaders
Source§impl Serialize for RateLimitHeaders
impl Serialize for RateLimitHeaders
impl Copy for RateLimitHeaders
impl Eq for RateLimitHeaders
impl StructuralPartialEq for RateLimitHeaders
Auto Trait Implementations§
impl Freeze for RateLimitHeaders
impl RefUnwindSafe for RateLimitHeaders
impl Send for RateLimitHeaders
impl Sync for RateLimitHeaders
impl Unpin for RateLimitHeaders
impl UnwindSafe for RateLimitHeaders
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