grpc-rust icon indicating copy to clipboard operation
grpc-rust copied to clipboard

Generate module definitions

Open DazWilkin opened this issue 4 years ago • 0 comments

I may be missing this but, protoc_rust_grpc (and the other crates) does not generate rust module definitions.

Other languages are configurable through protobuf Options and permit a language namespace to be specified (e.g. Java's "com.something" or Golang's "package").

This would be a useful feature for rust too and IIUC should also permit the generation of module defs

E.g.

protoc_rust_grpc::run(protoc_rust_grpc::Args {
    out_dir: "src/google/api",
    includes: &["googleapis"],
    input: &[
        "googleapis/google/api/annotations.proto",
        ...,
    ],
    rust_protobuf: true,
    ..Default::default()
})

Needs something of the form:

mod.rs:

pub mod google {
    pub mod api {
        pub mod annotations;
    }
}

As a noob, I'm having to manually enumerate the proto files in protoc_rust_grpc and then repeat this process for a hierarchy of mod.rs files that reflect the generated sources.

Perhaps there's a better way?

The code has sufficient information already:

  • Either: use the existing outdir, includes and input to determine the module hierarchy
  • Or: enable protobuf option rust_module = "google::api" to define the hierarchy

DazWilkin avatar Apr 13 '20 19:04 DazWilkin