I have a producer that pushes a bunch of bytes::Bytes (of variable sizes) onto a VecDeque. On the other end I want to take out, say, exactly 64K data (if available) at a time.
Is it possible to take a bunch of Bytes buffers and merge them into a single Bytes, without copying the actual data? (I.e. chain the internal rope buffers).
I know I can simply return a Vec<Bytes>, but the end-goal is to use chunks_vectored() and then do a vectored write, so it would be convenient if all of this could be done in one pass.
The Bytes type doesn't use ropes internally. It's essentially a smarter Arc<[u8]> where all the bytes are stored contiguously.
You'll probably want to make Queue::pull() return a custom wrapper that contains a Vec<Bytes> internally and give it a method to write to an impl std::io::Write using Write::write_vectored().
Interesting -- I don't know where I got the idea that it uses rope buffers internally, but I have believed it does for years.
I probably thought Bytes was akin to Apache's bucket brigades.
I'm genuinely confused by this -- I know that you know about IoSlice and write_vectored(), so I know I'm missing something here. Am I using "vectorized write" improperly?