[][src]Struct tide::http::other::RetryAfter

pub struct RetryAfter { /* fields omitted */ }

Indicate how long the user agent should wait before making a follow-up request.

MDN Documentation

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]

pub fn new(dur: Duration) -> RetryAfter[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) -> RetryAfter[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<RetryAfter>, Error>
[src]

Create a new instance from headers.

pub fn duration_since(
    &self,
    earlier: SystemTime
) -> Result<Duration, SystemTimeError>
[src]

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 Debug for RetryAfter[src]

impl Eq for RetryAfter[src]

impl Hash for RetryAfter[src]

impl Ord for RetryAfter[src]

impl PartialEq<RetryAfter> for RetryAfter[src]

impl PartialOrd<RetryAfter> for RetryAfter[src]

impl StructuralEq for RetryAfter[src]

impl StructuralPartialEq for RetryAfter[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,