Repository navigation
feat(internal/sidekick/rust): make GAPIC builders extensible - #7782
Conversation
…le_builders Allow Rust libraries to configure extensible_builders in librarian.yaml with a list of method IDs whose generated request builders expose pub(crate) internals. Services with at least one extensible builder emit pub(crate) fields on RequestBuilder, and methods in extensible_builders emit pub(crate) on their request builder tuple struct.
There was a problem hiding this comment.
Code Review
This pull request introduces support for "extensible builders" in the Rust generator by adding a new configuration option extensible_builders to specify method IDs whose generated request builders expose pub(crate) internals. The changes span configuration schema updates, Go codec parsing, and template modifications in builder.rs.gotmpl. The review feedback recommends simplifying the template modifications by using inline if directives to conditionally prepend pub(crate) to fields and structs, avoiding code duplication and keeping the template DRY.
| {{- else }} | ||
| #[derive(Clone, Debug)] | ||
| {{ .Codec.BuilderVisibility }} struct {{ .Codec.BuilderName }}(RequestBuilder<{{ .InputType.Codec.QualifiedName }}>); | ||
| {{ .Codec.BuilderVisibility }} struct {{ .Codec.BuilderName }}({{ if .Codec.ExtensibleBuilder }}pub(crate) {{ end }}RequestBuilder<{{ .InputType.Codec.QualifiedName }}>); |
There was a problem hiding this comment.
Does this work? Can tuples have field visibility?
There was a problem hiding this comment.
Apparently tuple structs can
Pick up googleapis/librarian#7782 and use it to move the source of truth for the custom poller implementation from librarian templates to google-cloud-rust
I did not go far enough in #7782. We also need this option available at the module level, not just the crate level.
🤖 I have created a release *beep* *boop* --- ## [0.49.0](v0.48.0...v0.49.0) (2026-10-19) ### Features * **internal/librarian/ruby:** copy sibling API `ruby_cloud_opts` ([#7789](#7789)) ([108eacd](108eacd)) * **internal/sidekick/rust:** extensible builders for module ([#7784](#7784)) ([7f41f9c](7f41f9c)) * **internal/sidekick/rust:** make GAPIC builders extensible ([#7782](#7782)) ([f64425b](f64425b)) * **internal/sidekick/rust:** mark keep modules as internal ([#7781](#7781)) ([6b0bf3b](6b0bf3b)) * **sidekick/swift:** mark .with helper as [@inlinable](https://github.com/inlinable) ([#7785](#7785)) ([984188e](984188e)) ### Bug Fixes * **internal/librarian/java:** strip google/devicesandservices/ prefix ([#7788](#7788)) ([49220d5](49220d5)) * **parser/protobuf:** resolve HttpBody wildcards ([#7780](#7780)) ([a30365b](a30365b)), refs [#7779](#7779) * **sidekick/swift:** configure client header at init ([#7792](#7792)) ([7b9c44c](7b9c44c)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Make the request object in a builder
pub(crate)as needed.We use a codec option instead of changing all GAPICs because our tooling would flag every crate as needing a version bump. We would rather keep the diff down and have one extra knob.
Motivation:
IsBigqueryInsertJobbusiness, moving handwritten code intogoogle-cloud-rust.