pub struct WebSocketRateLimiter { /* private fields */ }Expand description
Rate limiter for WebSocket connections
Implementations§
Source§impl WebSocketRateLimiter
impl WebSocketRateLimiter
Sourcepub fn new(config: RateLimitConfig) -> Self
pub fn new(config: RateLimitConfig) -> Self
Create new rate limiter with configuration
Sourcepub fn check_request(&self, ip: IpAddr) -> Result<(), RateLimitError>
pub fn check_request(&self, ip: IpAddr) -> Result<(), RateLimitError>
Check if request is allowed (HTTP upgrade to WebSocket)
Sourcepub fn check_connection(&self, ip: IpAddr) -> Result<(), RateLimitError>
pub fn check_connection(&self, ip: IpAddr) -> Result<(), RateLimitError>
Check if new connection is allowed
Sourcepub fn close_connection(&self, ip: IpAddr)
pub fn close_connection(&self, ip: IpAddr)
Register connection close
Sourcepub fn check_message(
&self,
ip: IpAddr,
frame_size: usize,
) -> Result<(), RateLimitError>
pub fn check_message( &self, ip: IpAddr, frame_size: usize, ) -> Result<(), RateLimitError>
Check if WebSocket message is allowed
Sourcepub fn get_stats(&self) -> RateLimitStats
pub fn get_stats(&self) -> RateLimitStats
Get current statistics for monitoring
Sourcepub fn cleanup_expired(&self)
pub fn cleanup_expired(&self)
Clean up expired entries (call periodically)
Trait Implementations§
Source§impl Debug for WebSocketRateLimiter
impl Debug for WebSocketRateLimiter
Auto Trait Implementations§
impl Freeze for WebSocketRateLimiter
impl !RefUnwindSafe for WebSocketRateLimiter
impl Send for WebSocketRateLimiter
impl Sync for WebSocketRateLimiter
impl Unpin for WebSocketRateLimiter
impl !UnwindSafe for WebSocketRateLimiter
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more