Package-based module structure
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Feature Request
### Crates
- `grpc-protobuf-build`
- `protoc-gen-rust-grpc`
### Motivation
In the past `prost-build` and `tonic-build` were structuring generated code in the same shape as packages in `.proto` files were structured. That was good. The same scoping in `.proto` files and Rust code ensured that there's no name conflicts in Rust code as long as there's no name conflicts in `.proto` files and that module structure is convenient in Rust code as long as it's convenient in `.proto` files. Sometimes it was slightly too verbose for a reason, but it's easy to create a convenient alias for a module with too long name.
Now `grpc-protobuf-build` structure generated code in a file-based tree and merge everything together with a lot of `use module_name::*`. This is not good. It creates name conflicts and completely melts away the package-based namespacing defined in `.proto` files. This can be overcome by manually compiling each file into its own module, then manually configuring dependencies between them, then manually generating a root module that structures generated modules into expected shape, which is extremely hard and inconvenient.
### Proposal
I suggest to add a feature (and probably make it default) for generating Rust code in modules structured the same way as packages in `.proto` files are structured.
Contributor guide
Research direction
Start by reading the grpc-protobuf-build and protoc-gen-rust-grpc crates to trace how generated modules are currently assembled. Compare that output with the package nesting in .proto files; done means a configurable package-based module structure that preserves package namespacing and addresses the reported name conflicts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- grpc, rust
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100