pub struct RateLimitMiddleware { /* private fields */ }Expand description
Middleware for rate limiting WebSocket connections
Implementations§
Source§impl RateLimitMiddleware
impl RateLimitMiddleware
Sourcepub fn new(config: RateLimitConfig) -> Self
pub fn new(config: RateLimitConfig) -> Self
Create new rate limit middleware
Sourcepub async fn check_connection(&self, ip: IpAddr) -> Result<bool>
pub async fn check_connection(&self, ip: IpAddr) -> Result<bool>
Check if a connection is allowed
Sourcepub async fn connection_closed(&self, ip: IpAddr)
pub async fn connection_closed(&self, ip: IpAddr)
Remove a connection from tracking
Sourcepub async fn stats(&self) -> RateLimitStats
pub async fn stats(&self) -> RateLimitStats
Get rate limiting statistics
Auto Trait Implementations§
impl !Freeze for RateLimitMiddleware
impl !RefUnwindSafe for RateLimitMiddleware
impl Send for RateLimitMiddleware
impl Sync for RateLimitMiddleware
impl Unpin for RateLimitMiddleware
impl !UnwindSafe for RateLimitMiddleware
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