How should I produce a single stream of items from this data structure?

⚓ rust    📅 2025-05-06    👤 surdeus    👁️ 4      

surdeus

Warning

This post was published 56 days ago. The information described in this article may have changed.

I have a Vec<Too> where Foo is a struct with a field which is a Tokio mpsc::Receiver.

I want to basically flatten all of these into one single Reciever. Ideally all of these inner receivers would have some kind of fairness when merging the receivers, so that each one gets a chance to produce the next message if there's something ready.

I've looked at the Stream adapters for Tokio's Receiver, but they take ownership of the Receiver type. I would think there must be some way to do it with a Vec<&mut Receiver>, which would be ideal since I still want the Foo struct to own the receiver.

Is there any way to do this? And anything simpler than trying to use Stream?

1 post - 1 participant

Read full topic

🏷️ rust_feed