Multi stream
Aggregate multiple streams of different types in a single stream with an item type that is a tuple of the incoming stream items.
Important
- The streams are polled and a new stream item is emitted if any if ANY of the streams emits a new value
- The values are cloned when the new stream value is emitted so incoming stream items must be clonable
- Items in the tuple being emitted are all returned in
Optionas their corresponding stream may never emit - The macro supports up to 12 input streams only
Example usage
- Add to your Cargo.toml file
[]
= "0.1.0"
- Import the
muti_streammacro and pass in stream instances to create a new stream:
use stream;
use StreamExt;
use multi_stream;
use random;
use Duration;
use sleep;
async