pub struct RateLimiter { /* private fields */ }Expand description
Semaphore-based per-API concurrency limiter.
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn new(config: RateLimitConfig) -> Self
pub fn new(config: RateLimitConfig) -> Self
Create a new rate limiter from the given configuration.
Sourcepub async fn acquire(&self, url: &str) -> OwnedSemaphorePermit
pub async fn acquire(&self, url: &str) -> OwnedSemaphorePermit
Acquire a permit for the given URL, blocking until one is available.
Sourcepub fn stats(&self) -> Vec<RateLimitStats>
pub fn stats(&self) -> Vec<RateLimitStats>
Get a snapshot of current rate limiting state.
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