Skip to main content

Wait

Struct Wait 

Source
pub struct Wait { /* private fields */ }
Expand description

A helper to wait until some event has passed.

Implementations§

Source§

impl Wait

Source

pub fn new(timeout: Duration, sleep: Duration) -> Self

Source

pub fn with_timeout(timeout: Duration) -> Self

Source

pub fn with_sleep(sleep: Duration) -> Self

Source

pub fn forever() -> Self

Source

pub fn until<F, G>(&self, predicate: F) -> Result<G, Timeout>
where F: FnMut() -> Option<G>,

Wait until the given predicate returns Some(G) or timeout arrives.

Note: If your predicate function shadows potential unexpected errors you should consider using #strict_until.

Source

pub fn strict_until<F, D, E, G>(&self, predicate: F, downcast: D) -> Result<G>
where F: FnMut() -> Result<G>, D: FnMut(Error) -> Result<E>,

Wait until the given predicate returns Ok(G), an unexpected error occurs or timeout arrives.

Errors produced by the predicate are downcasted by the additional provided closure. If the downcast is successful - the error is ignored, otherwise the wait is terminated and Err(error) containing the unexpected failure is returned to the caller.

You can use failure::Error::downcast::<YourStructName> out-of-the-box, if you need to ignore one expected error, or you can implement a matching closure that responds to multiple error types.

Trait Implementations§

Source§

impl Debug for Wait

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Wait

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Wait

§

impl RefUnwindSafe for Wait

§

impl Send for Wait

§

impl Sync for Wait

§

impl Unpin for Wait

§

impl UnsafeUnpin for Wait

§

impl UnwindSafe for Wait

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V