pub async fn wait_interface<S, B, St, F, T>(
stream: St,
init: &mut B,
predicate: F,
) -> Result<T, WatcherOperationError<S, B>>
Expand description
Wait for a condition on interface state to be satisfied.
With the initial state in init
, take events from stream
and update the state, calling
predicate
whenever the state changes. When predicate
returns Some(T)
, yield Ok(T)
.
Since the state passed via init
is mutably updated for every event, when this function
returns successfully, the state can be used as the initial state in a subsequent call with a
stream of events from the same watcher.