A protoc
plugin that generates code using the Prost! code generation engine.
When used in projects that use only Rust code, the preferred mechanism for
generating protobuf definitions with Prost! is to use prost-build
from
within a build.rs
file. However, when working in polyglot environments,
it can be advantageous to utilize common tooling in the Protocol Buffers
ecosystem. One common tool used for this purpose is buf, which simplifies
the code generation process and includes several useful features, including
linting, package management, and breaking change detection.
The various modules that are used for generating Rust code with Prost! and Tonic are available in the named subdirectories. Refer to the README in each of those folders for more information.
buf.gen.yaml
Note: When executing protoc-gen-prost-crate
with the gen_crate
option, remote
generation is not possible, as the manifest template is not made available to a
remote plugin.
version: v1
plugins:
- plugin: buf.build/community/neoeinstein-prost:v0.2.3
out: gen/src
opt:
- bytes=.
- compile_well_known_types
- extern_path=.google.protobuf=::pbjson_types
- file_descriptor_set
- plugin: buf.build/community/neoeinstein-prost-serde:v0.2.3
out: gen/src
- plugin: buf.build/community/neoeinstein-tonic:v0.3.0
out: gen/src
opt:
- compile_well_known_types
- extern_path=.google.protobuf=::pbjson_types
- plugin: prost-crate
out: gen
strategy: all
opt:
- gen_crate=Cargo.toml
See example/build-with-buf
for an example of invoking buf
as part of a
build.rs
build script. This may be useful when you want to extend the
generated files with additional trait or inherent implementations.