pub struct Wait { /* private fields */ }Expand description
A helper to wait until some event has passed.
Implementations§
Source§impl Wait
impl Wait
pub fn new(timeout: Duration, sleep: Duration) -> Self
pub fn with_timeout(timeout: Duration) -> Self
pub fn with_sleep(sleep: Duration) -> Self
pub fn forever() -> Self
Sourcepub fn until<F, G>(&self, predicate: F) -> Result<G, Timeout>
pub fn until<F, G>(&self, predicate: F) -> Result<G, Timeout>
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.
Sourcepub fn strict_until<F, D, E, G>(&self, predicate: F, downcast: D) -> Result<G>
pub fn strict_until<F, D, E, G>(&self, predicate: F, downcast: D) -> Result<G>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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