pub struct RateLimiter { /* private fields */ }Expand description
Rate limiter for API endpoints
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn new(config: RateLimitConfig) -> Self
pub fn new(config: RateLimitConfig) -> Self
Create a new rate limiter
Sourcepub fn check_request(
&self,
ip: IpAddr,
authenticated: bool,
) -> SecurityResult<()>
pub fn check_request( &self, ip: IpAddr, authenticated: bool, ) -> SecurityResult<()>
Check if a request is allowed
Sourcepub fn get_banned_ips(&self) -> Vec<(IpAddr, BanInfo)>
pub fn get_banned_ips(&self) -> Vec<(IpAddr, BanInfo)>
Get banned IPs
Sourcepub fn get_stats(&self) -> RateLimitStats
pub fn get_stats(&self) -> RateLimitStats
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