Skip to content

feat(generator/rust)!: use integers for enums#1448

Merged
coryan merged 4 commits intogoogleapis:mainfrom
coryan:prototype-i32-enums
Mar 10, 2025
Merged

feat(generator/rust)!: use integers for enums#1448
coryan merged 4 commits intogoogleapis:mainfrom
coryan:prototype-i32-enums

Conversation

@coryan
Copy link
Collaborator

@coryan coryan commented Mar 10, 2025

Change the enums to be integer-based as opposed to string-based. This
changes the API, so it is a breaking change. We need to make this change
to support client libraries based on gRPC. Unknown enums are received
as integers in that case. We need to make the change for all client
libraries, as any of them may need to switch the underlying transport if
they gain streaming RPCs.

Fixes #1379

coryan added 2 commits March 10, 2025 10:23
Change the enums to be integer-based as opposed to string-based. This
changes the API, so it is a breaking change. We need to make this change
to support client libraries based on gRPC. Unknown enums are received
as integers in that case. We need to make the change for all client
libraries, as any of them may need to switch the underlying transport if
they gain streaming RPCs.
@coryan coryan changed the title Prototype-i32-enums feat!(generator/rust): use integers for enums Mar 10, 2025
@coryan coryan changed the title feat!(generator/rust): use integers for enums feat(generator/rust)!: use integers for enums Mar 10, 2025
@coryan coryan marked this pull request as ready for review March 10, 2025 14:52
@coryan coryan requested review from codyoss and dbolduc March 10, 2025 14:52
@codecov
Copy link

codecov bot commented Mar 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.74%. Comparing base (ca711e2) to head (308df02).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    googleapis/google-cloud-rust#1448   +/-   ##
=======================================
  Coverage   66.74%   66.74%           
=======================================
  Files          39       39           
  Lines        2195     2195           
=======================================
  Hits         1465     1465           
  Misses        730      730           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@dbolduc dbolduc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems correct that openapi/.../model.rs is not changing, but I did not find exactly why.

enums must not be included as enum here for openapi?

var sysParams []systemParameter
if protobufSource {
sysParams = append(sysParams, systemParameter{
Name: "$alt", Value: "json;enum-encoding=int",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL, thanks @codyoss

@coryan
Copy link
Collaborator Author

coryan commented Mar 10, 2025

It seems correct that openapi/.../model.rs is not changing, but I did not find exactly why.

enums must not be included as enum here for openapi?

That is because we do not convert anything in OpenAPI to enums. At least, not yet: googleapis/librarian#1597

@coryan coryan merged commit a64b013 into googleapis:main Mar 10, 2025
20 checks passed
@coryan coryan deleted the prototype-i32-enums branch March 10, 2025 19:04
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.

Support enums encoded as numbers

2 participants