pub struct RateLimit<T> { /* private fields */ }Expand description
Async rate limit implementation
use std::time::Duration;
use rate_limit_wrapper::RateLimit;
#[tokio::main]
async fn main() {
// 10 requests per second
let rm = RateLimit::new(10, Duration::from_secs(1), reqwest::Client::new());
// Access inner client bypassing rate limit
let request = rm.as_ref().get("https://www.rust-lang.org").build().unwrap();
// Apply rate limit
let client = rm.rate_limit(1).await;
client.execute(request).await.unwrap();
}Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for RateLimit<T>
impl<T> RefUnwindSafe for RateLimit<T>where
T: RefUnwindSafe,
impl<T> Send for RateLimit<T>where
T: Send,
impl<T> Sync for RateLimit<T>where
T: Sync,
impl<T> Unpin for RateLimit<T>where
T: Unpin,
impl<T> UnsafeUnpin for RateLimit<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for RateLimit<T>where
T: UnwindSafe,
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