[−][src]Struct delay::Delay
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.
Methods
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]
initial: Duration,
multiplier: f32,
cap: Duration
) -> Self
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,