pub async fn wait_interface_with_id<S, St, F, T, I>(
stream: St,
init: &mut InterfaceState<S, I>,
predicate: F,
) -> Result<T, WatcherOperationError<S, InterfaceState<S, I>>>where
S: Default + Clone + Debug,
St: Stream<Item = Result<EventWithInterest<I>, Error>>,
F: FnMut(&PropertiesAndState<S, I>) -> Option<T>,
I: FieldInterests,
Expand description
Wait for a condition on a specific interface to be satisfied.
Note that stream
must be created from a watcher with interest in all
fields, such as one created from event_stream_from_state
.
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.