pub struct RateLimiter { /* private fields */ }Expand description
High-performance rate limiter using token bucket algorithm
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn new(capacity: usize, window: u64) -> Arc<Self>
pub fn new(capacity: usize, window: u64) -> Arc<Self>
Create a new rate limiter with default configuration
Sourcepub fn with_config(config: RateLimiterConfig) -> Arc<Self>
pub fn with_config(config: RateLimiterConfig) -> Arc<Self>
Create a new rate limiter with custom configuration
Sourcepub fn check_rate_limit(&self, identifier: IpAddr) -> RateLimitResult
pub fn check_rate_limit(&self, identifier: IpAddr) -> RateLimitResult
Check rate limit for a given identifier (usually IP address)
Sourcepub fn stats(&self) -> RateLimiterStats
pub fn stats(&self) -> RateLimiterStats
Get current statistics
Auto Trait Implementations§
impl !Freeze for RateLimiter
impl !RefUnwindSafe for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin for RateLimiter
impl UnwindSafe for RateLimiter
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