Struct garcon::Delay[][src]

pub struct Delay { /* fields omitted */ }
Expand description

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

Implementations

impl Delay[src]

pub fn from(inner: Box<dyn Waiter>) -> Self[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 side_effect<F>(function: F) -> Self where
    F: 'static + Sync + Send + Clone + Fn() -> Result<(), WaiterError>, 
[src]

Call a function every tick, expecting some kind of side effect (e.g. a progress bar).

pub fn builder() -> DelayBuilder[src]

Trait Implementations

impl Clone for Delay[src]

fn clone(&self) -> Self[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Waiter for Delay[src]

fn restart(&mut self) -> Result<(), WaiterError>[src]

Restart the wait timer. Call after starting the waiter otherwise returns an error. Read more

fn start(&mut self)[src]

Called when we start the waiting cycle.

fn wait(&mut self) -> Result<(), WaiterError>[src]

Called at each cycle of the waiting cycle. Call after starting the waiter otherwise returns an error. Read more

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<T> WaiterClone for T where
    T: 'static + Waiter + Clone
[src]

pub fn clone_box(&Self) -> Box<dyn Waiter + 'static, Global>[src]