I recently became curious about the different tools that are available to do one specific thing in Rust: provide an implementation of the
std::io::Write trait for an in-memory buffer.
This might be useful if you have serializable data that you want to store in a database, or if you want to add checksums or perform compression before storing or sending some data. It may also be useful for buffering ordinary network writes (though
BufWriter might be easier).
How can this be done in Rust? What's the most efficient way of buffering serialized data?