Struct http_types::other::RetryAfter [−][src]
pub struct RetryAfter { /* fields omitted */ }
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
impl RetryAfter
[src]
impl RetryAfter
[src]pub fn new(dur: Duration) -> Self
[src]
Create a new instance from a Duration
.
This value will be encoded over the wire as a relative offset in seconds.
pub fn new_at(at: SystemTime) -> Self
[src]
Create a new instance from a SystemTime
instant.
This value will be encoded a specific Date
over the wire.
pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
[src]
Create a new instance from headers.
pub fn duration_since(
&self,
earlier: SystemTime
) -> Result<Duration, SystemTimeError>
[src]
&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.
pub fn apply(&self, headers: impl AsMut<Headers>)
[src]
Sets the header.
pub fn name(&self) -> HeaderName
[src]
Get the HeaderName
.
pub fn value(&self) -> HeaderValue
[src]
Get the HeaderValue
.
Trait Implementations
impl Clone for RetryAfter
[src]
impl Clone for RetryAfter
[src]fn clone(&self) -> RetryAfter
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Eq for RetryAfter
[src]
impl Eq for RetryAfter
[src]impl Hash for RetryAfter
[src]
impl Hash for RetryAfter
[src]impl Ord for RetryAfter
[src]
impl Ord for RetryAfter
[src]impl PartialEq<RetryAfter> for RetryAfter
[src]
impl PartialEq<RetryAfter> for RetryAfter
[src]fn eq(&self, other: &RetryAfter) -> bool
[src]
fn ne(&self, other: &RetryAfter) -> bool
[src]
impl PartialOrd<RetryAfter> for RetryAfter
[src]
impl PartialOrd<RetryAfter> for RetryAfter
[src]impl StructuralEq for RetryAfter
[src]
impl StructuralEq for RetryAfter
[src]impl StructuralPartialEq for RetryAfter
[src]
impl StructuralPartialEq for RetryAfter
[src]Auto Trait Implementations
impl RefUnwindSafe for RetryAfter
impl RefUnwindSafe for RetryAfter
impl Send for RetryAfter
impl Send for RetryAfter
impl Sync for RetryAfter
impl Sync for RetryAfter
impl Unpin for RetryAfter
impl Unpin for RetryAfter
impl UnwindSafe for RetryAfter
impl UnwindSafe for RetryAfter