Skip to content

Conversation

@tkr-sh
Copy link

@tkr-sh tkr-sh commented May 5, 2025

By default, protos enums are converted to Rust i32. Which can be annoying / not convenient.

I created a new Config field - proto_enum_to_rust_enum - that, when activated, converts proto's enums into Rust's enum instead of i32,
The data transferred over the wire is exactly the same as i32. (See: prost-derive/src/field/enum_typed.rs)


Not sure where to put the test in prost-build/src/code_generator.rs?

@tkr-sh
Copy link
Author

tkr-sh commented May 5, 2025

This might be a partial fix to #276 btw

@Ten0
Copy link

Ten0 commented May 5, 2025

Related PR: #1079

@tkr-sh
Copy link
Author

tkr-sh commented May 5, 2025

Yes! But this one is really easy to implement since it keeps the same declaration of enums, it's just that the types used in messages (in the Rust representation) are enums.
I think that it could be a nice addition, even to #1079 in case you don't want to handle open enums.
Also, would be really easy to add support for Result<_, i32> #1079 (comment)

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