pub struct Throttler<const NUM_RECORDS: usize> { /* private fields */ }
Implementations§
Source§impl<const NUM_RECORDS: usize> Throttler<NUM_RECORDS>
impl<const NUM_RECORDS: usize> Throttler<NUM_RECORDS>
pub fn new( rate_limit: usize, period: Duration, naughty_timeout: Duration, max_tracking: Duration, ) -> Throttler<NUM_RECORDS>
Sourcepub fn check_throttle(
&mut self,
ip: IpAddr,
now: Option<Instant>,
count: Option<usize>,
) -> bool
pub fn check_throttle( &mut self, ip: IpAddr, now: Option<Instant>, count: Option<usize>, ) -> bool
Returns true if the provided IP is throttled.
pub fn get_num_records(&self) -> usize
Auto Trait Implementations§
impl<const NUM_RECORDS: usize> Freeze for Throttler<NUM_RECORDS>
impl<const NUM_RECORDS: usize> RefUnwindSafe for Throttler<NUM_RECORDS>
impl<const NUM_RECORDS: usize> Send for Throttler<NUM_RECORDS>
impl<const NUM_RECORDS: usize> Sync for Throttler<NUM_RECORDS>
impl<const NUM_RECORDS: usize> Unpin for Throttler<NUM_RECORDS>
impl<const NUM_RECORDS: usize> UnwindSafe for Throttler<NUM_RECORDS>
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