pub struct RateLimit {
pub limit: usize,
pub remaining: usize,
pub reset: ResetTime,
pub window: Option<Duration>,
pub vendor: Vendor,
}
Expand description
HTTP rate limits as parsed from header values
Fields§
§limit: usize
The maximum number of requests allowed in the time window
remaining: usize
The number of requests remaining in the time window
reset: ResetTime
The time at which the rate limit will be reset
window: Option<Duration>
The time window until the rate limit is lifted. It is optional, because it might not be given, in which case it needs to be inferred from the environment
vendor: Vendor
Predicted vendor based on rate limit header
Implementations§
Source§impl RateLimit
impl RateLimit
Sourcepub fn new<T: Into<CaseSensitiveHeaderMap>>(headers: T) -> Result<Self, Error>
pub fn new<T: Into<CaseSensitiveHeaderMap>>(headers: T) -> Result<Self, Error>
Extracts rate limits from HTTP headers separated by newlines
There are different header names for various websites Github, Vimeo, Twitter, Imgur, etc have their own headers. Without additional context, the parsing is done on a best-effort basis.
Trait Implementations§
impl Copy for RateLimit
impl StructuralPartialEq for RateLimit
Auto Trait Implementations§
impl Freeze for RateLimit
impl RefUnwindSafe for RateLimit
impl Send for RateLimit
impl Sync for RateLimit
impl Unpin for RateLimit
impl UnwindSafe for RateLimit
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