pub struct RateLimiter { /* private fields */ }Expand description
Rate limiter that tracks connections per IP address.
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn start_cleanup_task(&self, cleanup_interval: Duration)
pub fn start_cleanup_task(&self, cleanup_interval: Duration)
Start the background cleanup task.
Sourcepub fn check_and_increment(&self, ip: IpAddr) -> bool
pub fn check_and_increment(&self, ip: IpAddr) -> bool
Check if a connection from the given IP is allowed. Returns true if allowed, false if rate limited.
Trait Implementations§
Source§impl Debug for RateLimiter
impl Debug for RateLimiter
Auto Trait Implementations§
impl Freeze for RateLimiter
impl !RefUnwindSafe for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin for RateLimiter
impl UnsafeUnpin 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