pub struct RetryAfter { /* private fields */ }
Expand description
Indicate how long the user agent should wait before making a follow-up request.
§Specifications
§Examples
use http_types::other::RetryAfter;
use http_types::Response;
use std::time::{SystemTime, Duration};
use async_std::task;
let retry = RetryAfter::new(Duration::from_secs(10));
let mut headers = Response::new(429);
retry.apply(&mut headers);
// Sleep for the duration, then try the task again.
let retry = RetryAfter::from_headers(headers)?.unwrap();
task::sleep(retry.duration_since(SystemTime::now())?);
Implementations§
Source§impl RetryAfter
impl RetryAfter
Sourcepub fn new(dur: Duration) -> Self
pub fn new(dur: Duration) -> Self
Create a new instance from a Duration
.
This value will be encoded over the wire as a relative offset in seconds.
Sourcepub fn new_at(at: SystemTime) -> Self
pub fn new_at(at: SystemTime) -> Self
Create a new instance from a SystemTime
instant.
This value will be encoded a specific Date
over the wire.
Sourcepub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
Create a new instance from headers.
Sourcepub fn duration_since(
&self,
earlier: SystemTime,
) -> Result<Duration, SystemTimeError>
pub fn duration_since( &self, earlier: SystemTime, ) -> Result<Duration, SystemTimeError>
Returns the amount of time elapsed from an earlier point in time.
§Errors
This may return an error if the earlier
time was after the current time.
Sourcepub fn name(&self) -> HeaderName
pub fn name(&self) -> HeaderName
Get the HeaderName
.
Sourcepub fn value(&self) -> HeaderValue
pub fn value(&self) -> HeaderValue
Get the HeaderValue
.
Trait Implementations§
Source§impl Clone for RetryAfter
impl Clone for RetryAfter
Source§fn clone(&self) -> RetryAfter
fn clone(&self) -> RetryAfter
Returns a copy 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 From<RetryAfter> for SystemTime
impl From<RetryAfter> for SystemTime
Source§fn from(retry_after: RetryAfter) -> Self
fn from(retry_after: RetryAfter) -> Self
Converts to this type from the input type.
Source§impl Hash for RetryAfter
impl Hash for RetryAfter
Source§impl Ord for RetryAfter
impl Ord for RetryAfter
Source§fn cmp(&self, other: &RetryAfter) -> Ordering
fn cmp(&self, other: &RetryAfter) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for RetryAfter
impl PartialEq for RetryAfter
Source§impl PartialOrd for RetryAfter
impl PartialOrd 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 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