Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

satelit-project/protoc-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

protoc-rust

protoc plugin for Rust code generation based on top of prost and tonic.

Dependencies

  • Rust 1.39
  • Protobuf 3.7.1

Instalation

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.

Usage

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.

Customization

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 (See Config documentation for pitfalls).
  • extern-pathmap Protobuf types to Rust types