I have a list of streams which all generate items of the same type, and want to, in a loop:
get the item from the next ready stream
know which stream the item came from
I know about futures::stream::select_all, but this seems to discard information about which stream the item came from.
I think I want something like
use tokio_stream::wrappers::WatchStream;
type Item = ...;
let receivers: Vec<WatchStream<Item>> = ...;
let idx_items = ???(receivers);
while let Some((idx, item)) = idx_items.next().await {
}
use futures::stream::select_all::SelectAll;
let mut idx_items = SelectAll::new();
for (id, stream) for receivers {
idx_items.push(with_id(id, stream));
}
while let Some((idx, item)) = idx_items.next().await {
...
}