A Protocol Buffers builder for Rust (pb builder rs).
This is a small CLI tool that is designed to do two things:
- Patch any Protobuf files that use
editions instead of the
proto2orproto3syntax. - Generate a proper set of Rust modules that reflect the package structure of the source Protobuf definitions.
It uses prost Protobuf implementation via the tonic-prost-build crate.
- Prost does not currently support
editions. Some work is being
done there, but until it is completed, we can't compile
edition-enabled files with Prost. For the use cases this project is currently used, it is sufficient to simply swapedition = "2023";withsyntax = "proto3";, but it will not work as intended in all cases, for example in projects that take advantage of the edition features. - Prost generated code produces "flat" source files, one per package name. It
is designed to be run in
build.rsand subsequently included into the source code of the project using theinclude!(...)macro. This works in some situations, but doesn't scale well. One has to bring Protobuf files into each project where it needs to be used, maintain thebuild.rsfile, ensuring that module structure is correct, incurr additional penalty at build times, haveprotocinstalled in their environments, yada, yada. Withpbuildrs, one can generate the source code with a proper module structure that can be turned into a library/crate and reused across projects as needed.
This project is licensed under the MIT License.
For contribution guidelines see CONTRIBUTING.md.