#[non_exhaustive]pub struct RateLimit {
pub limit: u32,
pub remaining: u32,
pub retry_after: MangaDexDateTime,
}Expand description
This RateLimit struct contains all the data needed for rate limit handling
It can be parsed via a reqwest::Response or reqwest::header::HeaderMap
use mangadex_api_types_rust::rate_limit::{LIMIT, REMAINING, RETRY_AFTER, RateLimit, RateLimitParseError};
use reqwest::header::{HeaderMap, HeaderValue};
fn main() -> Result<(), RateLimitParseError> {
let mut headers = HeaderMap::new();
headers.append(RETRY_AFTER, HeaderValue::from_static("1698723860"));
headers.append(LIMIT, HeaderValue::from_static("40"));
headers.append(REMAINING, HeaderValue::from_static("39"));
assert_eq!(headers.len(), 3);
let rate_limit: RateLimit = TryFrom::try_from(&headers)?;
assert_eq!(rate_limit.limit, 40);
assert_eq!(rate_limit.remaining, 39);
Ok(())
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.limit: u32value from x-ratelimit-limit header
remaining: u32value from x-ratelimit-remaining header
retry_after: MangaDexDateTimevalue from x-ratelimit-retry-after header
It’s normally an i64 (Unix timestamp)
but can be parsed as a [crate::MangaDexDateTime]
Trait Implementations§
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