I have a dynamic number of "streams" (it's actually a Quinn crate RecvStream that doesn't implement the Copy trait) and I call this code on it:
let fut = stream.read(&mut buffer);
streams.push(fut);
The buffer
is a simple &[u8]
and the streams
is my instance of a futures::FuturesUnordered
.
This is great and I can use a Tokio select!
macro on streams.next()
. But I only get the number of bytes read back with no association with the data buffer and RecvStream
instance. This means I cannot reissue the read
operation to grab the next batch of data.
I've tried wrapping the future with another future that contains the stream and buffer who's associated type Output
is a tuple of its contents but have run into pinning issues. I was hoping this outer future could be pushed on to the FuturesUnordered
and I would have the stream and buffer to call read()
again and re-push.
Can anyone offer advice on how I should architect a solution where I retain the result of the future and the original association of the structures that created it in the first place?