fidl_fuchsia_net_interfaces_ext

Function 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>>
where S: Debug + Default, B: Update<S> + Clone + Debug, St: Stream<Item = Result<EventWithInterest<B::Interest>, Error>>, F: FnMut(&B) -> Option<T>,
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.