Eventually I will need a ByteStream for rusoto. So I thought I can create it from a futures::Stream:
pub fn z_stream(r: impl Read) -> Result<ByteStream> {
let outstream = stream::empty();
// TODO, how do I wrap outstream
process(r, &mut wrapped_outstream)?;
Ok(ByteStream::new(outstream))
}
I have a method process that takes 2 parameters, one for impl Read, the other for impl Write, where Read and Write come from std::io.
How do I wrap the outstream above into something that allows me to pass it to process? There's probably something already out there and I don't have to write my own wrapper?
You can't write to a
Streamin the same way you can't write to anIterator, they are read-only interfaces. You have to write to something else and then have that something else implement theStreamtrait so it can be read from. In your case, sinceprocessis sync, you can pass it aVec<u8>buffer to write to and then convert that buffer into aByteStreamusing theFrom<Vec<u8>>impl: