-
Notifications
You must be signed in to change notification settings - Fork 6
refactor: buffered #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
9f3a024 to
6c03582
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the buffered I/O implementation as the second stage of a larger refactoring effort. It reimplements BufReader with improved buffer management, adds BufWriter and LineWriter implementations, and reorganizes the module structure for better maintainability.
Key changes:
- Reorganized code into separate
read,write, andseekmodules for better separation of concerns - Reimplemented
BufReaderto useBox<[MaybeUninit<u8>]>whenallocis enabled, andheapless::Vecwith fixed capacity when disabled - Added
BufWriterandLineWriterwith similar dual-mode buffer management - Enhanced build configuration using
autocfgto detectmaybe_uninit_slicefeature availability
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib.rs | Updated to use new module structure, bumped edition to 2024, added DEFAULT_BUF_SIZE constant |
| src/prelude.rs | Updated import paths to use crate:: instead of super:: |
| src/read/mod.rs | Extracted Read trait and related functionality from lib.rs with additional helper functions |
| src/read/impls.rs | Implementations of Read/BufRead for standard types like slices, Box, VecDeque |
| src/write/mod.rs | New Write trait module with formatting support |
| src/write/impls.rs | Implementations of Write for standard types |
| src/seek/mod.rs | New Seek trait module extracted from lib.rs |
| src/seek/impls.rs | Forwarding implementations for &mut T and Box |
| src/buffered/mod.rs | Added exports for BufWriter, LineWriter, and IntoInnerError |
| src/buffered/bufreader/mod.rs | Reimplemented BufReader with new buffer abstraction |
| src/buffered/bufreader/buffer.rs | New internal buffer implementation supporting both alloc and no-alloc modes |
| src/buffered/bufwriter/mod.rs | New BufWriter implementation with dual-mode buffering |
| src/buffered/linewriter/mod.rs | New LineWriter wrapper around BufWriter |
| src/buffered/linewriter/shim.rs | Internal line-buffering logic implementation |
| build.rs | Added autocfg probe for maybe_uninit_slice feature |
| Cargo.toml | Updated axerrno to 0.2, added heapless and memchr dependencies, changed edition to 2024 |
| README.md | Enhanced documentation with feature descriptions and limitations |
| rustfmt.toml | New formatting configuration file |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6c03582 to
9ed9f57
Compare
9ed9f57 to
a0312c6
Compare
|
Typos found by Copilot has been reported upstream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Depends: #8
This is the second stage of refactoring, extracted from #4.
Changes
BufReaderallocfeature is enabled, use aBox<[MaybeUninit<u8>]>as buffer backend and useheapless::Vecwhich has a capacity limit ifallocfeature is disabled.BufWriterandLineWriterBufReader, useheapless::Vecinstead ofalloc::vec::Vecifallocfeature is disabled but the capacity is fixed.autocfgto check ifmaybe_uninit_sliceis stabilized on current compiler