chitralverma opened a new issue, #9323: URL: https://github.com/apache/opendal/issues/9323
*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 option structs, and the Go functional options that fill them, from core. Then expose the options both lack. One issue covers both bindings because `generate -l c` renders C and Go together and Go calls the C setters. Zig re-exports the C header ([`opendal.zig#L19`](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/zig/src/opendal.zig#L19)), so Zig users see the same structs. 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** - [`bindings/c/src/types.rs`](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/c/src/types.rs) defines the `#[repr(C)]` structs by hand, each with `_new`, `_free`, and `_set_*` functions and a conversion to core: | Struct | Defined | Converted | |---|---|---| | `opendal_list_options` | L136 | operator.rs L1271 | | `opendal_delete_options` | L282 | L360 | | `opendal_write_options` | L384 | L586 | | `opendal_stat_options` | L635 | L796 | | `opendal_read_options` | L829 | L1084 | | `opendal_reader_options` | L1135 | L1326 | | `opendal_copy_options` | L1361 | L1479 | - cbindgen ([build.rs#L25](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/c/build.rs#L25)) writes these structs into [`include/opendal.h`](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/c/include/opendal.h#L357), so field order and size are ABI. - `opendal_operator_rename` ([operator.rs#L1414](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/c/src/operator.rs#L1414)) and `opendal_operator_deleter` (L1731) take no options. - In Go, the `ReadWith*`, `WriteWith*`, and similar functions fill private structs ([reader.go#L221](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/go/reader.go#L221), L403; writer.go L174; stat.go L156; lister.go L84; delete.go L49; copy.go L78), which call the C setters through purego. The C structs are opaque to Go ([types.go#L65-L77](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/go/types.go#L65-L77)). [`ffi.go#L62`](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/go/ffi.go#L62) resolves every symbol Go declares when it loads the library. - `dev/src/generate/c.rs` generates only `Capability` and `Metadata`, for both C and Go. **Missing options (the same in C and Go)** - read: VM, VNM, `limit`, suffix ranges (`offset`/`length`, or Go `ReadWithRange`/`ReadWithRangeFrom`, only select forward ranges), 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` - rename: no options (`if_not_exists`) - compose, restore, deleter: no API, and the deleter takes no options **Step 1: generate the existing options with no API or ABI change** - Add a table in `c.rs` that maps each core field to its C member or members, setter name, and Go option name. It must record: - pointer constness: `start_after` (list) and `version` (delete) are `*mut c_char`, the rest are `*const c_char`; - `has_*` flags and sentinels: list `limit` uses 0 for unset, and Go treats zero values as unset; - timestamps as `i64` milliseconds since the Unix epoch; - string ownership: setters copy, and `_free` releases. - Also generate the compose, compose source, restore, and deleter option mirrors and their core conversions on the Rust side only, without `#[no_mangle]` exports, so `opendal.h`, the C ABI, Go, and the `opendal-go-services` companions are unchanged. Step 2 publishes them in `opendal.h` together with the operator functions that take them. Add a frozen-surface test whose expectations are literals copied from `main`'s `opendal.h`: each struct's field order and types, its `sizeof` and offsets, and the setter names and signatures. Add the same for Go's exported option functions. Prove both with a mutation. `ci_bindings_c.yml` and `ci_bindings_go.yml` already run `git diff --exit-code`. **Step 2: expose the missing options** - Append new members at the end of each struct. Callers that use `_new()` are unaffected, but `sizeof` grows, so declare an ABI change in `bindings/c/upgrade.md`, following the existing `opendal_capability` entry. - Add options-taking entry points for rename and the deleter, plus compose and restore functions. - Read `limit`: `opendal_read_options` also feeds `opendal_operator_presign_read_with` ([presign.rs#L204](https://github.com/apache/opendal/blob/4ae8e61222e6d282b2a1ec99db4e87dccacf5919/bindings/c/src/presign.rs#L204)), so document the `ConfigInvalid` conflicts with a positive `chunk`, with `concurrent` greater than one, and with presign. `opendal_reader_options` has no `limit`. - Suffix ranges: add a setter, for example `opendal_read_options_set_range_suffix`, and a matching Go option. - INC: take a `const opendal_metadata *` and copy it into the options. Core lowers it to a version or a non-weak ETag. - Go: adding `*With*` functions declares new C symbols. Release Go together with rebuilt `opendal-go-services` companions, and note it in `bindings/go/upgrade.md` as earlier symbol additions did. - 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 changes the C ABI layout and the Go companion requirements, so declare it in the `release_impact.py` format with `Affected packages` for C and Go. ### 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]
