You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Protobuf definition files can have a package directive in them. However, it doesn't appear that prost's Rust generation makes use of this other than when referencing previously defined types. The behaviour I would expect would be wrapping the content of the generated code with pub mod $packagename.
I tried using both protoc_gen_prost and prost-build, but they both produced the same results.
The prost-build documentation asks you to to define the modules yourself, and use the include! macro within to interpolate the generated code into the module. Moreover, you are required to match the module names exactly with the package directives as they appear in your proto files. Which begs the question, why can't that be done automatically?
Why is this extra step necessary, that is, why not generate the pub mod directive in each generated file?
I'm pretty new to Rust so it is very likely there is some obvious constraint at play here I'm not aware of. For background, as an experiment I'm feeding my team's project's large pile protobuf definitions into prost to see what the chances are of building working clients for our stuff in Rust. All of our proto files have package definitions.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey friends,
Protobuf definition files can have a
package
directive in them. However, it doesn't appear that prost's Rust generation makes use of this other than when referencing previously defined types. The behaviour I would expect would be wrapping the content of the generated code withpub mod $packagename
.I tried using both protoc_gen_prost and prost-build, but they both produced the same results.
The prost-build documentation asks you to to define the modules yourself, and use the
include!
macro within to interpolate the generated code into the module. Moreover, you are required to match the module names exactly with the package directives as they appear in your proto files. Which begs the question, why can't that be done automatically?Why is this extra step necessary, that is, why not generate the
pub mod
directive in each generated file?I'm pretty new to Rust so it is very likely there is some obvious constraint at play here I'm not aware of. For background, as an experiment I'm feeding my team's project's large pile protobuf definitions into prost to see what the chances are of building working clients for our stuff in Rust. All of our proto files have package definitions.
Cheers.
Beta Was this translation helpful? Give feedback.
All reactions