pub struct RateLimitEvent {
pub client_id: String,
pub event_type: RateLimitEventType,
pub current_count: u64,
pub limit: u64,
pub window_seconds: u64,
pub endpoint: Option<String>,
pub timestamp: DateTime<Utc>,
}Expand description
Record of a rate limit event
Fields§
§client_id: StringClient identifier
event_type: RateLimitEventTypeEvent type
current_count: u64Current request count
limit: u64Maximum allowed requests
window_seconds: u64Time window in seconds
endpoint: Option<String>Endpoint affected
timestamp: DateTime<Utc>Timestamp
Implementations§
Source§impl RateLimitEvent
impl RateLimitEvent
pub fn allowed( client_id: impl Into<String>, current: u64, limit: u64, window: u64, ) -> Self
pub fn limited( client_id: impl Into<String>, current: u64, limit: u64, window: u64, ) -> Self
pub fn with_endpoint(self, endpoint: impl Into<String>) -> Self
Sourcepub fn utilization(&self) -> f64
pub fn utilization(&self) -> f64
Calculate utilization percentage
Trait Implementations§
Source§impl Clone for RateLimitEvent
impl Clone for RateLimitEvent
Source§fn clone(&self) -> RateLimitEvent
fn clone(&self) -> RateLimitEvent
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 moreAuto Trait Implementations§
impl Freeze for RateLimitEvent
impl RefUnwindSafe for RateLimitEvent
impl Send for RateLimitEvent
impl Sync for RateLimitEvent
impl Unpin for RateLimitEvent
impl UnwindSafe for RateLimitEvent
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