Skip to main content

TimeoutConditionWaiter

Trait TimeoutConditionWaiter 

Source
pub trait TimeoutConditionWaiter: ConditionWaiter {
    // Required method
    fn wait_while_for<R, P, F>(
        &self,
        timeout: Duration,
        predicate: P,
        action: F,
    ) -> WaitTimeoutResult<R>
       where P: FnMut(&Self::State) -> bool,
             F: FnOnce(&mut Self::State) -> R;

    // Provided method
    fn wait_until_for<R, P, F>(
        &self,
        timeout: Duration,
        predicate: P,
        action: F,
    ) -> WaitTimeoutResult<R>
       where P: FnMut(&Self::State) -> bool,
             F: FnOnce(&mut Self::State) -> R { ... }
}
Expand description

Waits for predicates over protected state with relative timeouts.

Required Methods§

Source

fn wait_while_for<R, P, F>( &self, timeout: Duration, predicate: P, action: F, ) -> WaitTimeoutResult<R>
where P: FnMut(&Self::State) -> bool, F: FnOnce(&mut Self::State) -> R,

Blocks while the predicate remains true or until the timeout expires.

§Arguments
  • timeout - Maximum relative duration to wait.
  • predicate - Predicate that returns true while waiting should continue.
  • action - Action to run after the predicate becomes false.
§Returns

WaitTimeoutResult::Ready with the action result, or WaitTimeoutResult::TimedOut when the timeout expires first.

Provided Methods§

Source

fn wait_until_for<R, P, F>( &self, timeout: Duration, predicate: P, action: F, ) -> WaitTimeoutResult<R>
where P: FnMut(&Self::State) -> bool, F: FnOnce(&mut Self::State) -> R,

Blocks until the predicate becomes true or the timeout expires.

§Arguments
  • timeout - Maximum relative duration to wait.
  • predicate - Predicate that returns true when the state is ready.
  • action - Action to run after the predicate becomes true.
§Returns

WaitTimeoutResult::Ready with the action result, or WaitTimeoutResult::TimedOut when the timeout expires first.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§