This repository was archived by the owner on Dec 9, 2025. It is now read-only.
feat: add BufWriter and extend buffered I/O traits and impls #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new
BufWritertype for buffered writing, expands trait implementations for references, and adds new utility methods for buffered I/O. It also makes some dependency and import updates to support these features.Buffered I/O Enhancements:
BufWritertype for buffered writing, including its implementation and integration into the public API. This allows efficient batched writes similar toBufReaderfor reads. (src/buffered/writer.rs,src/buffered/mod.rs,src/lib.rs,src/prelude.rs)BufWritetrait, analogous toBufRead, with methods for flushing internal buffers, skipping bytes, and writing plain-old-data (POD) types. (src/lib.rs)BufRead:read_valfor reading POD types andread_cstringfor reading C-style strings. (src/lib.rs)Trait Implementation Improvements:
Read,Write,Seek,BufRead, andBufWritefor mutable references to types that implement those traits, improving composability and ergonomics. (src/impls.rs)src/impls.rs)Dependency and Code Organization:
bytemuckcrate (with thederivefeature) as a dependency to enable safe POD reads and writes. (Cargo.toml)DEFAULT_BUF_SIZEconstant to a shared location and updated its usage for consistency. (src/buffered/mod.rs,src/buffered/reader.rs,src/buffered/writer.rs)These changes collectively modernize and extend the buffered I/O capabilities of the crate, making it easier to use and more feature-rich.
After that, I will submit a PR to support netlink based on this PR.