Skip to content

Conversation

@AsakuraMizu
Copy link
Contributor

@AsakuraMizu AsakuraMizu commented Dec 22, 2025

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

Changes

  • Improve the project structure and organize traits by module
  • Upgrade to 2024 edition
  • Add more information to README.md, update crate description and documentation
  • Add following methods to traits:
    • Read::read_buf/Read::read_buf_exact/Read::by_ref
    • BufRead::skip_until/BufRead::split/BufRead::lines
    • Seek::stream_len/Seek::seek_relative
  • Add more trait implementations
  • Use memchr to optimize BufRead::read_until (also used in BufRead::skip_until)
  • Update axerrno to 0.2

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 implements the first stage of refactoring for the axio crate, reorganizing the project structure and expanding functionality to better align with std::io.

Key Changes:

  • Reorganized code by splitting traits into separate modules (read, write, seek) with dedicated implementation files
  • Added new trait methods including Read::read_buf, Read::read_buf_exact, BufRead::skip_until, BufRead::split, BufRead::lines, Seek::stream_len, and Seek::seek_relative
  • Integrated memchr crate for optimized byte searching in BufRead::read_until and BufRead::skip_until

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Cargo.toml Updated edition to 2024, bumped axerrno dependency to 0.2, added memchr dependency
README.md Enhanced documentation with feature descriptions, differences from std::io, limitations, and license information
src/lib.rs Refactored to use module-based organization, added DEFAULT_BUF_SIZE constant, re-exported types from axerrno
src/prelude.rs Updated documentation example and import path to use crate:: instead of super::
src/write/mod.rs New module defining Write trait with write, flush, write_all, write_fmt, and by_ref methods
src/write/impls.rs Implementations of Write trait for references, Box, byte slices, Vec, VecDeque, and BorrowedCursor
src/seek/mod.rs New module defining Seek trait and SeekFrom enum with additional methods stream_len and seek_relative
src/seek/impls.rs Forwarding implementations of Seek trait for references and Box
src/read/mod.rs New module defining Read and BufRead traits with expanded functionality, including Split and Lines iterators
src/read/impls.rs Comprehensive implementations of Read and BufRead for various types including slices, Box, VecDeque
src/error.rs Deleted - functionality moved to lib.rs via re-exports from axerrno
src/impls.rs Deleted - implementations reorganized into module-specific impls.rs files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AsakuraMizu AsakuraMizu changed the title refactor: (stage 1) refactor: project structure, enhance basic traits Dec 22, 2025
This was referenced Dec 24, 2025
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 15 out of 15 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AsakuraMizu
Copy link
Contributor Author

The value of DEFAULT_BUF_SIZE needs to be discussed.

In std it is configured as follows:

// Bare metal platforms usually have very small amounts of RAM
// (in the order of hundreds of KB)
pub const DEFAULT_BUF_SIZE: usize = if cfg!(target_os = "espidf") { 512 } else { 8 * 1024 };

512 seems a bit small for us, while 8 * 1024 is a bit large. I've currently chosen 2 * 1024, which is right in between.

@Azure-stars
Copy link

The value of DEFAULT_BUF_SIZE needs to be discussed.

In std it is configured as follows:

// Bare metal platforms usually have very small amounts of RAM
// (in the order of hundreds of KB)
pub const DEFAULT_BUF_SIZE: usize = if cfg!(target_os = "espidf") { 512 } else { 8 * 1024 };

512 seems a bit small for us, while 8 * 1024 is a bit large. I've currently chosen 2 * 1024, which is right in between.

Can we support different size via feature like https://github.com/arceos-org/arceos/blob/main/modules/axalloc/Cargo.toml#L17-L18?

Because we may be used at different platforms.

@AsakuraMizu
Copy link
Contributor Author

AsakuraMizu commented Dec 26, 2025

Can we support different size via feature like arceos-org/arceos@main/modules/axalloc/Cargo.toml#L17-L18?

Because we may be used at different platforms.

That sounds reasonable. But now we need to select a suitable set of default buffer sizes.

@AsakuraMizu
Copy link
Contributor Author

AsakuraMizu commented Dec 30, 2025

Oh, now there's a problem. Should we silently ignore Error::Interrupted like std? I hadn't thought much about it before, but now it seems like we shouldn't; all errors should be reported. @Azure-stars

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.

3 participants