pub struct RateLimiter { /* private fields */ }Expand description
Inner rate-limiting state shared behind a Mutex.
Implementations§
Source§impl RateLimiter
impl RateLimiter
pub fn new( requests_per_second: f64, burst_size: u32, max_tracked_ips: usize, ) -> RateLimiter
pub fn with_trust_proxy(self, trust: bool) -> RateLimiter
Sourcepub async fn tracked_ip_count(&self) -> usize
pub async fn tracked_ip_count(&self) -> usize
Current number of tracked client IPs (for tests).
Sourcepub fn retry_after_secs(&self) -> u64
pub fn retry_after_secs(&self) -> u64
Seconds a client should wait before retrying (RFC 6585 Retry-After).
A bucket refills one token every 1 / rate seconds; a whole second is
the smallest useful hint, and 1s is used when the rate is unset.
Auto Trait Implementations§
impl !Freeze for RateLimiter
impl !RefUnwindSafe for RateLimiter
impl !UnwindSafe for RateLimiter
impl Forget for RateLimiter
impl Move for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin for RateLimiter
impl UnsafeUnpin 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