Here is reduced copy of what I met in .proto files of real service. This service is out of my control, I just want to create client for it.
proto/foo.proto
syntax = "proto3";
package foo;
import "foo/bar.proto";
message Bar {
oneof bar {
bar.This this = 1;
bar.That that = 2;
}
}
proto/foo/bar.proto
syntax = "proto3";
package foo.bar;
message This {}
message That {}
src/lib.rs
pub mod foo {
include!(concat!(env!("OUT_DIR"), "/foo.rs"));
pub mod bar {
include!(concat!(env!("OUT_DIR"), "/foo.bar.rs"));
}
}
Such proto files lead to error:
error[E0428]: the name `bar` is defined multiple times
--> /Users/kriomant/.cargo/target/debug/build/proto-67d1c5fed5b166e2/out/foo.rs:8:1
|
8 | pub mod bar {
| ^^^^^^^^^^^ `bar` redefined here
|
::: src/lib.rs:3:5
|
3 | pub mod bar {
| ----------- previous definition of the module `bar` here
|
= note: `bar` must be defined only once in the type namespace of this module
This is because each message with 'oneof' field generates module with name corresponding to that message name.
In this case it conflicts with existing proto package.
Here is reduced copy of what I met in .proto files of real service. This service is out of my control, I just want to create client for it.
proto/foo.proto
proto/foo/bar.proto
src/lib.rs
Such proto files lead to error:
This is because each message with 'oneof' field generates module with name corresponding to that message name. In this case it conflicts with existing proto package.