Function fidl_fuchsia_net_interfaces_ext::wait_interface
source · 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.
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.