fidl_fuchsia_pkg_ext

Function fidl_iterator_to_stream

Source
pub fn fidl_iterator_to_stream<T: FidlIterator>(
    iterator: T,
) -> impl Stream<Item = Result<Vec<T::Item>, Error>> + Unpin
Expand description

Converts a proxy to a FIDL iterator like:

protocol PayloadIterator { Next() -> (vector:MAX payloads); };

into a Stream of Result<Vec<Payload>, fidl::Error>s.

The returned stream will never yield an empty Vec. When e.g. PayloadIterator::Next returns an empty Vec, the returned stream will yield None (signaling the end of the stream).

To use with a new protocol (e.g. PayloadIterator), implement FidlIterator for PayloadIteratorProxy.