Skip to content

refactor: split part of read.rs for code readability#744

Merged
Its-Just-Nans merged 22 commits into
masterfrom
refactor-part-of-read-rs
Mar 22, 2026
Merged

refactor: split part of read.rs for code readability#744
Its-Just-Nans merged 22 commits into
masterfrom
refactor-part-of-read-rs

Conversation

@Its-Just-Nans

@Its-Just-Nans Its-Just-Nans commented Mar 21, 2026

Copy link
Copy Markdown
Member

Currently src/read.rs is 25xx line long which is a lot

It contains a lot of things, even including AesInfo which is only for aes, datetime function, ZipFileData functions

This MR

  • moves the mod zip_archive inside a clean file src/read/zip_archive.rs and the corresponding tests
  • move code related to readers to src/read/readers.rs
  • move AesInfo to src/aes.rs
  • move some datetime functions to src/datetime.rs

After this MR src/read.rs is now 13xx lines, containing

  • merge function (not moved)
  • extract functions (not moved)
  • ZipFile*

@Its-Just-Nans Its-Just-Nans self-assigned this Mar 21, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request undertakes a substantial refactoring of the src/read.rs module to enhance code organization and maintainability. By extracting ZipArchive and reader-specific logic into new sub-modules, the original file's complexity is drastically reduced. This modular approach clarifies responsibilities, makes the codebase easier to navigate, and sets a stronger foundation for future development and feature additions.

Highlights

  • Module Restructuring: The src/read.rs file, previously over 2500 lines long, has been significantly refactored by moving distinct functionalities into new, dedicated sub-modules: src/read/zip_archive.rs and src/read/readers.rs.
  • ZipArchive Logic Centralization: All ZipArchive related structures, metadata, and methods have been moved to src/read/zip_archive.rs, improving the organization of archive handling logic.
  • Reader-Specific Implementations: Types and functions related to file reading, such as CryptoReader, ZipFileReader, SeekableTake, make_crypto_reader, and make_reader, have been extracted into src/read/readers.rs.
  • AES Information Relocation: The AesInfo struct, which holds AES encryption details, has been moved from src/read.rs to src/aes.rs.
  • Datetime Function Integration: Datetime utility functions, including datetime_to_systemtime and generate_chrono_datetime, have been integrated as methods directly into the DateTime struct within src/datetime.rs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactoring successfully reorganizes the codebase by extracting reader-related code and archive functionality into separate modules. The changes improve code organization without introducing any functional defects that would block merging.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Comment thread src/types.rs
&self,
reader: &'a mut R,
) -> ZipResult<Take<&'a mut R>> {
// TODO: use .get_or_try_init() once stabilized to provide a closure returning a Result!

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great refactoring that significantly improves the modularity of the read module by splitting the large read.rs file into smaller, more focused files. The code has been moved to new files like src/read/zip_archive.rs, src/read/readers.rs, src/aes.rs, and src/datetime.rs, which makes the codebase easier to navigate and maintain. I have one minor suggestion regarding a typo.

Comment thread src/datetime.rs Outdated
@Its-Just-Nans Its-Just-Nans changed the title Refactor part of read rs refactor: split part of read.rs for code readability Mar 21, 2026
@Its-Just-Nans Its-Just-Nans added this pull request to the merge queue Mar 22, 2026
Merged via the queue into master with commit bae095b Mar 22, 2026
131 checks passed
@Its-Just-Nans Its-Just-Nans deleted the refactor-part-of-read-rs branch March 22, 2026 23:37
@Pr0methean Pr0methean mentioned this pull request Mar 22, 2026
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