protoc
plugin for Rust code generation based on top of
prost
and
tonic
.
- Rust 1.39
- Protobuf 3.7.1
Plugin can be installed via cargo install
:
cargo install protoc-rust \
--git "https://github.com/satelit-project/protoc-rust" \
--tag 0.2.0-beta.1 \
--force
You can also specify custom binary location via --root
argument.
Invoke protoc
directly:
protoc \
--plugin=protoc-gen-rust="$(which protoc-gen-rust)" \
--proto_path=<protos include path> \
--rust_out=<output directory> \
<proto file>...
Or use custom tools like protogen
like in satelit-proto
project.
You can customize plugin behaviour by passing flags directly to the
plugin via --rust_opt
protoc
's argument. For example: protoc --rust_opt=grpc,no-flat-modules
.
Available flags are:
grpc
– generate code for gRPC services.grpc-client
– generate client side code for gRPC services.grpc-server
– generate server side code for gRPC services.no-flat-modules
– map protobuf packages to Rust modules (SeeConfig
documentation for pitfalls).extern-path
– map Protobuf types to Rust types