pub struct RateLimiter { /* private fields */ }Expand description
Rate limiter for API requests
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn new(requests_per_minute: u32) -> RateLimiter
pub fn new(requests_per_minute: u32) -> RateLimiter
Create a new rate limiter
Sourcepub fn can_make_request(&mut self) -> bool
pub fn can_make_request(&mut self) -> bool
Check if a request can be made
Sourcepub fn remaining_requests(&self) -> u32
pub fn remaining_requests(&self) -> u32
Get remaining requests in current window
Trait Implementations§
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