pub enum RetryAfter {
Delay(Duration),
Date(RetryAfterDate),
}Expand description
Parsed value of an HTTP Retry-After response header.
The header supports two forms (RFC 9110 §10.2.3):
- Delta-seconds: a non-negative integer —
Retry-After: 120 - HTTP-date: an RFC 7231 date —
Retry-After: Wed, 21 Oct 2015 07:28:00 GMT
§Parsing
use api_bones::retry::RetryAfter;
use core::time::Duration;
let delay: RetryAfter = "120".parse().unwrap();
assert_eq!(delay, RetryAfter::Delay(Duration::from_secs(120)));
let date: RetryAfter = "Wed, 21 Oct 2015 07:28:00 GMT".parse().unwrap();
matches!(date, RetryAfter::Date(_));Variants§
Delay(Duration)
A relative delay expressed as a Duration.
Date(RetryAfterDate)
An absolute point-in-time expressed as an RFC 7231 HTTP-date string.
Stored as a raw string to avoid a mandatory chrono dependency.
Parse it with chrono::DateTime::parse_from_rfc2822 when the
chrono feature is enabled.
Tuple Fields
§
0: RetryAfterDateRaw HTTP-date string (RFC 7231 / RFC 5322 format).
Trait Implementations§
Source§impl Clone for RetryAfter
impl Clone for RetryAfter
Source§fn clone(&self) -> RetryAfter
fn clone(&self) -> RetryAfter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RetryAfter
impl Debug for RetryAfter
Source§impl<'de> Deserialize<'de> for RetryAfter
impl<'de> Deserialize<'de> for RetryAfter
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for RetryAfter
Available on crate features std or alloc only.
impl Display for RetryAfter
Available on crate features
std or alloc only.Source§impl FromStr for RetryAfter
Available on crate features std or alloc only.
impl FromStr for RetryAfter
Available on crate features
std or alloc only.Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parse a Retry-After header value.
Tries delta-seconds first; falls back to HTTP-date.
§Errors
Returns RetryAfterParseError when the value is neither a valid
non-negative integer nor a parseable HTTP-date string.
Source§type Err = RetryAfterParseError
type Err = RetryAfterParseError
The associated error which can be returned from parsing.
Source§impl PartialEq for RetryAfter
impl PartialEq for RetryAfter
Source§impl Serialize for RetryAfter
impl Serialize for RetryAfter
impl Eq for RetryAfter
impl StructuralPartialEq for RetryAfter
Auto Trait Implementations§
impl Freeze for RetryAfter
impl RefUnwindSafe for RetryAfter
impl Send for RetryAfter
impl Sync for RetryAfter
impl Unpin for RetryAfter
impl UnsafeUnpin for RetryAfter
impl UnwindSafe for RetryAfter
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<T> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP