pub async fn serve_fidl_iterator_from_stream<I>(
fidl_iterator: I,
stream: impl Stream<Item = Vec<<I::Responder as FidlIteratorNextResponder>::Item>> + Unpin,
max_stream_chunks: usize,
) -> Result<()>where
I: FidlIteratorRequestStream,Expand description
Serves fidl iterators like:
protocol PayloadIterator {
Next() -> (vector
from:
fidl_iterator: effectively a stream of PayloadIterator::Next requests
stream: a Stream<Vecmax_stream_chunks: the maximum number of Vec<Payload>’s to pull from stream at a time.
Making this number larger can pack more Payloads into the fidl response, decreasing
overhead, but the buffer of Vec<Payload>s is pre-allocated, so if this number is e.g.
usize::MAX the program will OOM. This number is the maximum, not the minimum, i.e
serve_fidl_iterator_from_stream will not block on stream if there are available
Payloads to send. Arguments of 0 will be converted to 1.
Fills each response to Next() with as many available entries as will fit in a fidl message.
Only blocks on stream if there are no available entries.
The returned future completes after Next() yields an empty response or the iterator
is interrupted (client closes the channel or the task encounters a FIDL layer error).
To use with a new protocol (e.g. PayloadIterator), in this crate:
- implement
FidlIteratorRequestStreamforPayloadIteratorRequestStream - implement
FidlIteratorNextResponderforPayloadIteratorNextResponder - implement
MeasurableforPayloadusing functions generated by //tools/fidl/measure-tape