[−][src]Module twitchchat::rate_limit
This is supported on
feature="tokio"
only.A simple leaky-bucket style token-based rate limiter
This'll block the calling task if tokens aren't available
Example
let mut rate = RateLimit::empty(3, Duration::from_millis(10)); assert_eq!(rate.take().await, 2); assert_eq!(rate.take().await, 1); assert_eq!(rate.take().await, 0); assert!(rate.take().now_or_never().is_none()); // we're blocking // give it some time to refill delay_for(Duration::from_millis(15)).await; assert_eq!(rate.take().await, 2); // we're unblocked
Structs
RateLimit | feature="tokio" A leaky-bucket style token-based rate limiter |
Enums
RateClass | feature="tokio" A preset number of tokens as described by Twitch |