chitralverma opened a new issue, #9324: URL: https://github.com/apache/opendal/issues/9324
*Drafted with AI assistance (Claude Code, Claude Opus 5.5, effort xhigh); the author is accountable for it.* ### Feature Description Generate the C++ binding's operation options from core, then expose the options C++ lacks. Part of #9320. Abbreviations: VM/VNM = `if_version_match`/`if_version_not_match`, INC = `if_not_changed`. Links point at `4ae8e61222`. ### Problem and Solution **Current code.** Each option lives in four hand-written places: 1. Public aggregates in [`include/data_structure.hpp`](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/cpp/include/data_structure.hpp#L78): `StatOptions` (L78), `ReadOptions` (L93), `ReaderOptions` (L113), `WriteOptions` (L130), `CopyOptions` (L148), `RenameOptions` (L161), `DeleteOptions` (L169), and `ListOptions` (L178). `ReadRange` (L47) already supports `Suffix`. 2. cxx mirrors `Ffi*Options` in [`src/lib.rs#L79-L158`](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/cpp/src/lib.rs#L79-L158). 3. The C++-to-FFI `ToFfiOptions` overloads in [`src/operator.cpp#L94-L188`](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/cpp/src/operator.cpp#L94-L188). 4. The FFI-to-core conversions in [`src/lib.rs#L418-L520`](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/cpp/src/lib.rs#L418-L520). The sync `Operator` methods take these options ([opendal.hpp#L103-L207](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/cpp/include/opendal.hpp#L103-L207)). The async API takes none. `dev/src/generate/cpp.rs` generates only `Capability` and `Metadata`. **Missing options** - read: VM, VNM, `limit`, and `checksum` - reader: VM, VNM, and `checksum` - stat: VM, VNM, and `checksum` - write: `content_language`, `expires`, VM, VNM, INC, and `checksum` - list: `glob` - delete: `if_match`, `if_none_match`, VM, VNM, and INC - copy: `if_none_match`, VM, VNM, INC, `user_metadata`, `content_type`, and `content_language` - compose, restore, deleter: no API. The async API takes no options at all. **Step 1: generate the existing options with no API change** - Add a table in `cpp.rs` that maps each core field to its C++ member type and default member initializer. Render all four places from it: the header, the cxx mirror, `ToFfiOptions`, and the Rust conversion. - Also generate the compose, compose source, restore, and deleter cxx mirrors and Rust conversions, without adding them to the public headers or `Operator`. Step 2 publishes the public structs together with the `Operator` methods that take them. Behavior that step 1 must preserve: - Member order, because positional brace-init and C++20 designated initializers depend on it. - Member types: `std::optional<std::string>`, `std::optional<std::chrono::system_clock::time_point>`, `std::optional<std::size_t>`, `std::optional<std::uint64_t>`, and `std::optional<std::unordered_map<std::string, std::string>>`. - Default member initializers, such as `concurrent{0}` and `bool ...{false}`. - `clang-format` output (the Google style the generator already targets, cpp.rs L51). Add a frozen-surface test whose expectations are literals copied from `main`'s `data_structure.hpp`: each struct's member names, types, initializers, and order. Prove it with a mutation. `ci_bindings_cpp.yml` already runs `git diff --exit-code`. **Step 2: expose the missing options** - Append new members at the end of each struct. Appending keeps positional and designated initializers valid, but it changes size and layout, so declare a rebuild requirement in `bindings/cpp/upgrade.md`. - Read `limit`: `ReadOptions` feeds only `Read`. Document the `ConfigInvalid` conflicts with a positive `chunk` and with `concurrent` greater than one. `ReaderOptions` has no `limit`. - INC: accept an `opendal::Metadata`. The generated converter goes only from core to C++ today (`parse_metadata`, `src/utils/metadata_converter.cpp`), so this needs the reverse direction. Core lowers it to a version or a non-weak ETag. - Compose, restore, and deleter: add the `Operator` methods and wire the step-1 types. - Blocked by #9319: write-side VM, VNM, and INC, plus compose `if_version_match` and `if_not_changed`. Copy conditions are not blocked: GCS does not advertise `copy_with_if_not_exists`, so the copy request builder never receives the combination that #9319 covers. The `checksum` fields follow #9316. ### Additional Context Step 1 is not a release-impacting change. Step 2 is source-compatible but changes struct layout, so declare it in the `release_impact.py` format with `Affected packages` for C++. ### Are you willing to contribute to the development of this feature? - [x] Yes, I am willing to contribute to the development of this feature. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
