Crate bufreaderwriter[][src]

The BufReaderWriter<RW> is a convenience struct that facilitates automatic switching between buffered reading and writing from a single underlying Read + Write + Seek instance (generally applicable for std::fs::File). BufReaderWriter moves the underlying instance between a BufReader and BufWriter as needed.

The reader/writer needs to be seekable as switching from reading to writing involves discarding the read buffer and seeking the underlying reader/writer back to the current position of the BufReader.


use bufreaderwriter::BufReaderWriter;
use tempfile::tempfile;

fn main() -> io::Result<()> {
    let mut brw = BufReaderWriter::new_writer(tempfile()?);
    let data = "The quick brown fox jumps over the lazy dog".to_owned();
    let mut bin = vec![0; data.len()]; bin)?;