Skip to content

Conversation

@sftse
Copy link
Contributor

@sftse sftse commented Oct 29, 2025

Supersedes #572

@sftse
Copy link
Contributor Author

sftse commented Oct 29, 2025

Not sure what the rules of semantic versioning say about functions that are not callable but manage to be visible. VbaProject::from_cfb appears in the public documentation but is not callable because Cfb is not pub. This PR makes it pub(crate).

@jmcnamara
Copy link
Collaborator

This PR makes it pub(crate).

+1. It was unnecessarily public. I dropped it completely in my cfb.rs PR and just used VbaProject::new().

@jmcnamara
Copy link
Collaborator

I have no major comments on this. Overall it looks very good. I'll try do a full review in a few days.

In the meantime I'll kick off copilot. Just ignore/resolve any irrelevant comments.

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 VBA project API to simplify error handling and ownership semantics. The main change converts vba_project() from returning Option<Result<Cow<'_, VbaProject>, Error>> to Result<Option<VbaProject>, Error>, eliminating the Cow wrapper and inverting the Option/Result nesting for more idiomatic Rust error handling.

Key changes:

  • Changed vba_project() signature from Option<Result<Cow<'_, VbaProject>, Error>> to Result<Option<VbaProject>, Error> across all workbook types
  • Removed redundant XmlAttribute error variant in XlsxError, consolidating it with existing XmlAttr variant
  • Refactored Xls to store Cfb and reader internally, enabling lazy VBA loading instead of eager loading
  • Updated all test cases and examples to use the new API pattern

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/lib.rs Updated Reader trait signature for vba_project() and updated documentation example
src/vba.rs Made from_cfb() internal, updated documentation, and added derive traits to VbaProject
src/xlsx/mod.rs Removed duplicate XmlAttribute error variant, simplified error handling, and updated vba_project() implementation
src/xlsb/mod.rs Updated vba_project() implementation and added missing error conversions
src/xls.rs Refactored to store Cfb and reader for lazy VBA loading, updated vba_project() implementation
src/ods.rs Updated vba_project() signature (ODS doesn't support VBA) and fixed error conversion
src/cfb.rs Added derive traits to XlsEncoding and simplified Vec::with_capacity logic
src/auto.rs Updated vba_project() implementation for auto-detected workbook wrapper
src/xlsx/cells_reader.rs Simplified error handling by removing redundant map_err calls
tests/test.rs Updated all test cases to use new VBA API and added VBA reference/module tests
examples/search_errors.rs Updated to use new VBA API pattern
fuzz/fuzz_targets/fuzz_all.rs Updated to use new VBA API pattern
README.md Updated documentation example

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

@jmcnamara
Copy link
Collaborator

Overall this look good to me. @sftse are you happy to merge?

@sftse
Copy link
Contributor Author

sftse commented Nov 3, 2025

GTM

@jmcnamara jmcnamara merged commit 1df80c8 into tafia:master Nov 3, 2025
11 checks passed
@jmcnamara
Copy link
Collaborator

Merged. Thanks.

@sftse sftse deleted the vba-project branch November 3, 2025 11:13
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