pub struct RateLimiter { /* private fields */ }Expand description
Rate limiter
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub async fn acquire(&self) -> Result<SemaphorePermit<'_>>
pub async fn acquire(&self) -> Result<SemaphorePermit<'_>>
Acquire permit (blocks until available)
Sourcepub fn try_acquire(&self) -> Option<SemaphorePermit<'_>>
pub fn try_acquire(&self) -> Option<SemaphorePermit<'_>>
Try to acquire permit (non-blocking)
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Get current number of available permits
Sourcepub fn max_permits(&self) -> usize
pub fn max_permits(&self) -> usize
Get maximum number of permits
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