[][src]Struct delay::Delay

pub struct Delay { /* fields omitted */ }

A Delay struct that encapsulates a Waiter.

To use this class, first create an instance of it by either calling a method on it (like Delay::timeout) or create a builder and add multiple Waiters. Then when you're ready to start a process that needs to wait, use the [start()] function. Every wait period, call the [wait()] function on it (it may block the thread). When you're done, you may call [stop()].

Waiters can be reused and re-started, but most would expect to have [stop()] called on them when you do, to free any additional resources.

Implementations

impl Delay[src]

pub fn instant() -> Self[src]

A Delay that never waits. This can hog resources, so careful.

pub fn timeout(timeout: Duration) -> Self[src]

A Delay that doesn't wait, but times out after a while.

pub fn count_timeout(count: u64) -> Self[src]

A Delay that times out after waiting a certain number of times.

pub fn throttle(throttle: Duration) -> Self[src]

A delay that waits every wait() call for a certain time.

pub fn exponential_backoff_capped(
    initial: Duration,
    multiplier: f32,
    cap: Duration
) -> Self
[src]

A delay that recalculate a wait time every wait() calls and exponentially waits. The calculation is new_wait_time = max(current_wait_time * multiplier, cap).

pub fn exponential_backoff(initial: Duration, multiplier: f32) -> Self[src]

A delay that recalculate a wait time every wait() calls and exponentially waits. The calculation is new_wait_time = current_wait_time * multiplier. There is no limit for this backoff.

pub fn builder() -> DelayBuilder[src]

Trait Implementations

impl Clone for Delay[src]

impl Waiter for Delay[src]

Auto Trait Implementations

impl !RefUnwindSafe for Delay

impl Send for Delay

impl Sync for Delay

impl Unpin for Delay

impl !UnwindSafe for Delay

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> 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.