Expand description

Asynchronous extensions to Expectation Predicates This module defines a framework for using the crate::expectations module in asynchronous situations, where you wish you detect the satisfiability of the expectations at some undetermined point in the future.

An ExpectationFuture implements Future and will complete when the underlying state satisfies the predicate. Failure can be detected by wrapping the future in a timeout, as is implemented by the method when_satisfied.

To use ExpectationFutures, you must implement ExpectableState for the type of state you wish to track, which defines how the state will update and notify tasks that are waiting on state changes.

A common pattern is to await the expectation of a given state, and then check further predicate expectations to determine success or failure at that point in time.

e.g.

// Wait for the action to have completed one way or the other
let state = state.when_satisfied(action_complete, timeout).await?;
// Then check that the action completed successfully
action_success.satisfied(state)

Structs§

  • Inner state for the Expectable helper type
  • Future that completes once a Predicate is satisfied for the T::State type where T is some type that allows monitoring of State updates

Traits§

Functions§

Type Aliases§

  • Expectable<S,A> is an easy way to build an implementation of ExpectableState to await upon. The Aux type A is commonly used to hold a FIDL Proxy to drive the behavior under test.