Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable type names for pbjson_types #118

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

amfaber
Copy link

@amfaber amfaber commented Dec 2, 2023

Hiya!

Thanks for the great work in making it easier to switch between protobuf and json / other serde encodings. I recently ran into an issue where I had to use the prost_types::Any type though. Prost's any provides some nice methods for going to and from prost::Message's, but they require the trait bound prost::Name. Name is not implemented on prost-generated types by default, but this can trivially be opted into by called .enable_type_names() on the config. An even more ergonomic change would be to also implement from_msg and to_msg on pbjson_types::Any, but simply deriving prost::Name on all the standard types atleast lets the end user use prost's Any by shuffing around the structs a bit.

Before merging, I believe a few things should be settled:

  1. Is the feature even needed / wanted?
  2. Should it perhaps be behind a feature flag? Since the additional generated code is such low volume, I estimate it to be fine to just have it on by default
  3. Whether to also implement from_msg and to_msg on pbjson_types::Any

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.

1 participant