pub struct RateLimiter { /* private fields */ }Expand description
Tracks authentication attempts per source IP address.
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn check_attempt(&mut self, ip: IpAddr) -> bool
pub fn check_attempt(&mut self, ip: IpAddr) -> bool
Check whether an authentication attempt from this IP should be allowed.
Returns true if the attempt is permitted, false if the
IP is currently banned or has exceeded the attempt limit.
Sourcepub fn record_success(&mut self, ip: IpAddr)
pub fn record_success(&mut self, ip: IpAddr)
Reset the counter for an IP after a successful authentication.
Sourcepub fn tracked_count(&self) -> usize
pub fn tracked_count(&self) -> usize
Return the number of tracked IPs (for monitoring).
Trait Implementations§
Source§impl Debug for RateLimiter
impl Debug for RateLimiter
Source§impl Default for RateLimiter
impl Default for RateLimiter
Source§fn default() -> RateLimiter
fn default() -> RateLimiter
Returns the “default value” for a type. Read more
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