Struct delay_queue::Delay [] [src]

pub struct Delay<T> {
    pub value: T,
    // some fields omitted
}

Wraps a value that should be delayed.

Implements Delayed and Eq. Two Delay objects are equal iff their wrapped values are equal and they are delayed until the same Instant.

Examples

Basic usage:

use delay_queue::{Delay, Delayed};
use std::time::{Duration, Instant};

let delayed_one_hour = Delay::for_duration(123, Duration::from_secs(3600));
let delayed_now = Delay::until_instant("abc", Instant::now());

assert!(delayed_one_hour.delayed_until() > delayed_now.delayed_until());
assert_eq!(delayed_one_hour.value, 123);

Fields

The value that is delayed.

Methods

impl<T> Delay<T>
[src]

[src]

Creates a new Delay<T> holding value and that is delayed until the given Instant.

Examples

Basic usage:

use delay_queue::Delay;
use std::time::Instant;

let delayed_now = Delay::until_instant("abc", Instant::now());

[src]

Creates a new Delay<T> holding value and that is delayed until the given Duration has elapsed.

Examples

Basic usage:

use delay_queue::Delay;
use std::time::Duration;

let delayed_one_hour = Delay::for_duration("abc", Duration::from_secs(3600));

Trait Implementations

impl<T: Debug> Debug for Delay<T>
[src]

[src]

Formats the value using the given formatter.

impl<T: PartialEq> PartialEq for Delay<T>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<T: Eq> Eq for Delay<T>
[src]

impl<T> Delayed for Delay<T>
[src]

[src]

Returns the Instant until which this value is delayed.

impl<T: Default> Default for Delay<T>
[src]

[src]

Creates an expired Delay<T> with a default value.