Expand description
Additional Useful Stream Combinators and Utilities
Streams always signal exhaustion with None return values. A stream epitaph can be used when
a specific value is desired as the last item returned by a stream before it is exhausted.
Example usecase: often streams will be used without having direct access to the stream itself
such as from a streammap::StreamMap or a futures::stream::FuturesUnordered. Occasionally,
it is necessary to perform some cleanup procedure outside of a stream when it is exhausted. An
epitaph can be used to uniquely identify which stream has ended within a collection of
streams.
Structs§
- Future
Map - A collection of Future indexed by key, allowing removal by Key. When polled, a FutureMap yields
from whichever member future is ready first.
The Future type
Futcan be?Unpin, as all futures are stored as pins inside the map. The Key typeKmust beUnpin; it is unlikely that an!Unpintype would ever be needed as a Key. FutureMap yields items of type Fut::Output. - OneOr
Many - A collection of multiple futures that optimizes for the single-future case.
- Short
Circuit - Short circuits a [
TryStream] stream when the first error occurs. - Stream
Map - A collection of Stream indexed by key, allowing removal by Key. When polled, a StreamMap yields
from whichever member stream is ready first.
The Stream type
Stcan be?Unpin, as all streams are stored as pins inside the map. The Key typeKmust beUnpin; it is unlikely that an!Unpintype would ever be needed as a Key. StreamMap yields items of type St::Item; For a stream that yields messages tagged with their Key, consider using theIndexedStreamstype alias or using theTaggedcombinator. - Stream
With Epitaph - A
Streamthat returns the values of the wrapped stream until the wrapped stream is exhausted. Then it returns a single epitaph value before being exhausted - Tagged
- A Stream where each yielded item is tagged with a uniform key Items yielded are (K, St::Item)
Enums§
- Stream
Item - Values returned from a stream with an epitaph are of type
StreamItem.
Traits§
- With
Epitaph - Extension trait to allow for easy creation of a
StreamWithEpitaphfrom aStream. - WithTag
- Extension trait to allow for easy creation of a
Taggedstream from aStream.
Type Aliases§
- Indexed
Streams - Convenient alias for a collection of Streams indexed by key where each message is tagged and stream termination is notified by key. This is especially useful for maintaining a collection of fidl client request streams, and being notified when each terminates