-
Notifications
You must be signed in to change notification settings - Fork 526
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
Add file_descriptor
option to prost-build
#311
Conversation
d55187a
to
c27da8b
Compare
This commit adds support for including an encoded version of the appropriate `FileDescriptorProto` in each generated Rust module in the form of a `&'static [u8]` named `FILE_DESCRIPTOR`. This is disabled by default, and is enabled by setting `file_descriptor(true)` in a `Config` builder.
This should fix CI errors reported upstream.
c27da8b
to
3fe3e40
Compare
A few thoughts in no particular order: The correspondence between .proto files and generated Rust modules is n:1, not 1:1. As such, I think if you were to test this with two I think this would be more elegantly expressed with Looking at the provided link on gRPC server reflection, the corresponding C++ code uses |
Perhaps a better approach would be to include the FileDescriptorSet instead of the FileDescriptor. I'm not sure if there's an obvious place to 'mount' that, though. Perhaps |
Ah, I didn't quite appreciate that there was not a 1-1 correspondence between generated Rust modules and protocol buffers files. My original approach was to write out the I think in the short term it's fine to just write out the |
That sounds good to me! |
This pull request adds support for including an encoded version of the appropriate
FileDescriptorProto
in each generated Rust module in the form of a&'static [u8]
namedFILE_DESCRIPTOR
. This is disabled by default, and is enabled by settingfile_descriptor(true)
in aConfig
builder.The rationale for this pull request is to support the gRPC Server Reflection Protocol, which operates in terms of
FileDescriptorProto
, in Tonic.