pub struct RateLimiter { /* private fields */ }Expand description
Simple sliding-window rate limiter with a concurrency semaphore.
Implementations§
Source§impl RateLimiter
impl RateLimiter
pub fn new(max_per_minute: u32, max_concurrent: usize) -> Self
Sourcepub async fn acquire(
&self,
_domain: &str,
) -> Result<SemaphorePermit<'_>, FetchError>
pub async fn acquire( &self, _domain: &str, ) -> Result<SemaphorePermit<'_>, FetchError>
Check whether a request to domain is allowed.
Returns a permit that must be held for the duration of the request.
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