Crates.io | bufreaderwriter |
lib.rs | bufreaderwriter |
version | 0.2.4 |
source | src |
created_at | 2020-12-05 23:58:45.221381 |
updated_at | 2023-05-22 17:41:23.353404 |
description | Rust convenience structs that facilitate automatic switching between buffered reading and writing from a single underlying IO instance. BufReaderWriterRand for random IO and BufReaderWriterSeq for sequential IO. |
homepage | |
repository | https://github.com/alemigo/bufreaderwriter-rs |
max_upload_size | |
id | 319989 |
size | 25,239 |
The BufReaderWriterRand<RW>
and BufReaderWriterSeq<RW>
are convenience structs that facilitate automatic
switching between buffered reading and writing from a single underlying IO instance. BufReaderWriterRand
is
for random access IO (i.e. Read + Write + Seek, such as std::fs::File
), while BufReaderWriterSeq
is for sequential
IO (i.e. Read + Write, such as std::net::TcpStream
).
Both structs move the underlying IO instance between a BufReader and BufWriter as needed. However, when switching from
reading to writing, BufReaderWriterRand
discards any buffered data and seeks the underlying IO instance back to the
current BufReader position, while BufReaderWriterSeq
saves any buffered data and makes it available for subsequent
reads.