Skip to content

Improve error handling for the Iterator trait implementations.#8

Merged
wangfu91 merged 5 commits intomainfrom
dev
Jul 25, 2025
Merged

Improve error handling for the Iterator trait implementations.#8
wangfu91 merged 5 commits intomainfrom
dev

Conversation

@wangfu91
Copy link
Owner

This pull request introduces enhancements to error handling and type consistency across the usn-journal-rs library. The changes primarily focus on updating iterators to yield Result types, enabling more robust error handling during iteration, and introducing a unified UsnResult type alias for standardizing error handling. Additionally, it improves logging and formatting for error messages.

wangfu91 added 5 commits July 25, 2025 23:22
Added IntoIterator trait implementations for both Mft and &Mft, allowing them to be used directly in for loops and iterator-based APIs. This improves ergonomics when iterating over Mft entries.
The MFT iterator now yields UsnResult<MftEntry> instead of MftEntry, ensuring errors during enumeration are properly surfaced to users rather than being silently ignored. Example code, documentation, and tests have been updated to handle the new result type, providing better error visibility and consistency with the USN journal iterator.
Replaces all instances of format!("...", ...) and related macro calls with the Rust 1.58+ inline format string syntax (e.g., format!("{var}")). This modernizes the code, improves readability, and removes the clippy::uninlined_format_args allowance.
Updated documentation and README examples to clarify that USN journal and MFT iterators yield Result items, allowing individual entry errors to be handled gracefully. Improved code examples to demonstrate error handling for each entry.
@wangfu91 wangfu91 self-assigned this Jul 25, 2025
Copilot AI review requested due to automatic review settings July 25, 2025 17:05
Copy link
Contributor

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 pull request improves error handling for iterator implementations in the usn-journal-rs library by making iterators yield Result types instead of panicking on errors. It also standardizes error handling with a new UsnResult type alias and modernizes string formatting throughout the codebase.

  • Updated UsnJournalIter and MftIter to yield Result<T, UsnError> items for better error handling
  • Introduced UsnResult<T> type alias for consistent error handling patterns
  • Modernized string formatting from format!("{}", var) to format!("{var}") syntax

Reviewed Changes

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

Show a summary per file
File Description
src/lib.rs Adds UsnResult type alias and updates documentation examples to handle Result types
src/journal.rs Updates UsnJournalIter to yield Result<UsnEntry, UsnError> and modernizes formatting
src/mft.rs Updates MftIter to yield Result<MftEntry, UsnError> and adds error handling documentation
src/volume.rs Modernizes string formatting in logging and debug statements
src/tests.rs Updates string formatting in test utility functions
src/path.rs Modernizes string formatting in path construction
examples/*.rs Updates examples to handle the new Result-yielding iterators
README.md Updates documentation examples to show proper error handling

@wangfu91 wangfu91 merged commit 352c9f8 into main Jul 25, 2025
1 check passed
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