prost icon indicating copy to clipboard operation
prost copied to clipboard

Package shouldn't be required

Open maxlambrecht opened this issue 4 years ago • 1 comments

The protocol-buffers states: You can add an optional package specifier to a .proto file.

As prost is requiring a package , correct proto files missing the package can't be processed. This is a limitation and impacts interoperability.

Solution: use option rust_package = "helloworld" for the rust package. This is analogous to what other libraries in other languages use, like go_package, java_package, etc.

maxlambrecht avatar Jan 16 '21 17:01 maxlambrecht

The use-case I have is creating a client library for the SPIFFE Workload API: https://github.com/spiffe/go-spiffe/blob/master/proto/spiffe/workload/workload.proto

maxlambrecht avatar Mar 03 '21 18:03 maxlambrecht

Not sure if this problem still exists. If your proto file doesn't contain a package name, it will be written to _.rs in the out/ directory during the build process, which is awkward. You can use prost_build::Config::default_package_name to fix this. Note that this method doesn't seem to expect the .rs file name extension to be part of the argument, which isn't documented properly yet. I generally think that it's better to include a path in the build script rather than modifying the proto file for anything Rust related. See also this post on URLO.

JanBeh avatar Feb 03 '23 11:02 JanBeh