THIS IS NOT THE PLUGIN PUBLISHED ON CRATES.IO.
If you installed the plugin through cargo install protoc-gen-tonic
, then the
plugin you installed is the one from https://github.com/neoeinstein/protoc-gen-prost.
This repository is kept for visibility and because some people depend on it.
A protoc
plugin to generate Tonic code.
This is the complementary plugin to
protoc-gen-prost
, but with
the added gRPC stack provided by Tonic.
While the recommended way to use tonic
in Rust projects is with tonic-build
and running protoc
through Cargo and build.rs
, a protoc plugin allows to
get a standard workflow in the protobuf ecosystem. Also, precompiling proto
files to Rust code as files has some advantages:
- easier to share compiled code across multiple projects, since they don't all need to setup the prost build
- rust code can be stored in an easy to browse fashion (git, ...)
- integrates well with standard protobuf/grpc/... tooling
- compatible with
buf
cargo install protoc-gen-tonic
protoc -I proto --tonic_out=hello-rs hello.proto
Please note that, as opposed to protoc-gen-go-grpc
that works in addition
to protoc-gen-go
, protoc-gen-tonic
integrates the functionality of the
prost
plugin. Thus you do not need to run both plugin to get the message and
service code generation, only this plugin.
Please refer to the protoc-gen-prost
for detailed usage reference, including
module / crate generation. All options exposed by protoc-gen-prost
are
available with this plugin through the --tonic_opt
flag. The following options
are specific to protoc-gen-tonic
and are imported from tonic_build
, please
refer to
tonic_build::Builder
documentation for detailed documentation. Note that a few of those are imported
from prost_build
and exposed as well, but by protoc-gen-prost
.
no_build_client
: disable client code generationno_build_server
: disable server code generationserver_mod_attribute=<key>=<value>
, repeatableserver_attribute=<key>=<value>
, repeatableclient_mod_attribute=<key>=<value>
, repeatableclient_attribute=<key>=<value>
, repeatableproto_path=<value>
: stringdisable_package_emission
: boolean