pub struct RateLimit {
pub limit: u32,
pub interval: Duration,
}Expand description
The request budget crossref grants a client.
Read back from a live client with Crossref::rate_limit.
Fields§
§limit: u32how many requests are allowed within interval
interval: Durationthe window that limit applies to
Implementations§
Source§impl RateLimit
impl RateLimit
Sourcepub const CONSERVATIVE: Self
pub const CONSERVATIVE: Self
The budget assumed until crossref has reported one.
Deliberately below what either pool actually grants. The first response
carries the real figure, so guessing low costs nothing but a slightly
slower first handful of requests, whereas guessing high costs a 429.
Sourcepub fn spacing(&self) -> Duration
pub fn spacing(&self) -> Duration
The gap to leave between two requests to spend the budget evenly.
Sourcepub fn from_headers(headers: &HeaderMap) -> Option<Self>
pub fn from_headers(headers: &HeaderMap) -> Option<Self>
Reads the budget crossref reported on a response.
Returns None unless both headers are present and understood.
Trait Implementations§
impl Copy for RateLimit
impl Eq 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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.