Skip to content

Conversation

@ladvoc
Copy link
Contributor

@ladvoc ladvoc commented Oct 11, 2025

This PR derives from_variants on generated enums representing oneof fields from the FFI protocol, allowing a message to be converted into its corresponding oneof variant using into. This results in a significant boilerplate reduction in the FFI implementation.

@ladvoc ladvoc marked this pull request as ready for review October 11, 2025 01:32
Copy link

@1egoman 1egoman left a comment

Choose a reason for hiding this comment

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

Makes sense to me!

Only one minor thought - how common are enum field that contain the same struct, resulting in conflicts in the from_variants implementations? Is it worth trying to think about some sort of more scalable solution than just piecemeal adding from_variants_skip_field to handle these or are they fairly uncommon?

@ladvoc
Copy link
Contributor Author

ladvoc commented Oct 15, 2025

Makes sense to me!

Only one minor thought - how common are enum field that contain the same struct, resulting in conflicts in the from_variants implementations? Is it worth trying to think about some sort of more scalable solution than just piecemeal adding from_variants_skip_field to handle these or are they fairly uncommon?

Good point! I did think about this, but I think this situation is pretty uncommon. A more scalable solution would be creating a custom proc_macro, but I think we should cross that bridge later if it becomes an issue.

@ladvoc ladvoc merged commit 82ba55d into main Oct 15, 2025
10 of 11 checks passed
@ladvoc ladvoc deleted the ladvoc/from-variants branch October 15, 2025 03:29
@github-actions github-actions bot mentioned this pull request Oct 15, 2025
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.

3 participants