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 value
s 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
value: T
The value that is delayed.
Methods
impl<T> Delay<T>
[src]
fn until_instant(value: T, until: Instant) -> Delay<T>
[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());
fn for_duration(value: T, duration: Duration) -> Delay<T>
[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]
impl<T: PartialEq> PartialEq for Delay<T>
[src]
fn eq(&self, __arg_0: &Delay<T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Delay<T>) -> bool
[src]
This method tests for !=
.
impl<T: Eq> Eq for Delay<T>
[src]
impl<T> Delayed for Delay<T>
[src]
fn delayed_until(&self) -> Instant
[src]
Returns the Instant
until which this value is delayed.