pub struct RateLimiter { /* private fields */ }๐Deprecated:
Use the governor-based rate limiting in RainyClient instead
Expand description
A simple rate limiter.
This rate limiter is deprecated and should not be used in new code.
The RainyClient now uses a more robust, feature-flagged rate limiting mechanism
based on the governor crate.
Implementationsยง
Sourceยงimpl RateLimiter
impl RateLimiter
Sourcepub fn new(requests_per_minute: u32) -> Self
pub fn new(requests_per_minute: u32) -> Self
Creates a new RateLimiter.
ยงArguments
requests_per_minute- The maximum number of requests allowed per minute.
Sourcepub async fn wait_if_needed(&mut self) -> Result<()>
pub async fn wait_if_needed(&mut self) -> Result<()>
Pauses execution if the rate limit has been exceeded.
This method will asynchronously wait until the next request can be sent without violating the rate limit.
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 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