pub struct RateLimiter { /* private fields */ }Expand description
Rate limiter for network requests
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn new(min_interval: Duration) -> Self
pub fn new(min_interval: Duration) -> Self
Create a new rate limiter with minimum interval between requests
Sourcepub fn check_and_update(&mut self) -> bool
pub fn check_and_update(&mut self) -> bool
Check if request is allowed; returns true if allowed, false if rate-limited
Sourcepub async fn wait_if_needed(&mut self)
pub async fn wait_if_needed(&mut self)
Wait until next request is allowed
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