Skip to content

Conversation

@AsakuraMizu
Copy link
Contributor

Depends: #8

This is the second stage of refactoring, extracted from #4.

Changes

  • Reimplement BufReader
    • If alloc feature is enabled, use a Box<[MaybeUninit<u8>]> as buffer backend and use heapless::Vec which has a capacity limit if alloc feature is disabled.
  • Add BufWriter and LineWriter
    • Similar to BufReader, use heapless::Vec instead of alloc::vec::Vec if alloc feature is disabled but the capacity is fixed.
  • Use autocfg to check if maybe_uninit_slice is stabilized on current compiler

Copy link

Copilot AI left a 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, and seek modules for better separation of concerns
  • Reimplemented BufReader to use Box<[MaybeUninit<u8>]> when alloc is enabled, and heapless::Vec with fixed capacity when disabled
  • Added BufWriter and LineWriter with similar dual-mode buffer management
  • Enhanced build configuration using autocfg to detect maybe_uninit_slice feature 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.

@AsakuraMizu
Copy link
Contributor Author

Typos found by Copilot has been reported upstream.

Copy link

Copilot AI left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants