pub struct IdentifyRateLimiter { /* private fields */ }Expand description
Rate limiter for Gateway identify operations.
Discord allows max_concurrency identify operations every 5 seconds.
This rate limiter ensures we don’t exceed this limit.
Implementations§
Source§impl IdentifyRateLimiter
impl IdentifyRateLimiter
Sourcepub fn new(max_concurrency: usize) -> Self
pub fn new(max_concurrency: usize) -> Self
Create a new identify rate limiter.
§Arguments
max_concurrency- Maximum concurrent identifies (from /gateway/bot).
Sourcepub async fn acquire(&self)
pub async fn acquire(&self)
Acquire permission to send an Identify payload.
This will block until a slot is available. The slot is automatically released after 5 seconds.
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Get the number of available permits.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IdentifyRateLimiter
impl !RefUnwindSafe for IdentifyRateLimiter
impl Send for IdentifyRateLimiter
impl Sync for IdentifyRateLimiter
impl Unpin for IdentifyRateLimiter
impl !UnwindSafe for IdentifyRateLimiter
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