|  | ||
|---|---|---|
| .. | ||
| src | ||
| .cargo_vcs_info.json | ||
| Android.bp | ||
| Cargo.lock | ||
| Cargo.toml | ||
| Cargo.toml.orig | ||
| LICENSE | ||
| LICENSE.txt | ||
| METADATA | ||
| MODULE_LICENSE_MIT | ||
| NOTICE | ||
| OWNERS | ||
| README.md | ||
| cargo2android.json | ||
		
			
				
				README.md
			
		
		
			
			
		
	
	Protobuf code generator
This crate contains protobuf code generator implementation
and a protoc-gen-rust protoc plugin.
This crate:
- provides protoc-gen-rustplugin forprotoccommand
- implement protobuf codegen
This crate is not meant to be used directly, in fact, it does not provide any public API
(except for protoc-gen-rust binary).
Code can be generated with either:
- protoc-gen-rustplugin for- protocor
- protoc-rustcrate (code generator which depends on- protocbinary for parsing of- .protofiles)
- protobuf-codegen-purecrate, similar API to- protoc-rust, but uses pure rust parser of- .protofiles.
protoc-gen-rust plugin for protoc
When non-cargo build system is used, consider using standard protobuf code generation pattern:
protoc command does all the work of handling paths and parsing .proto files.
When protoc is invoked with --rust_out= option, it invokes protoc-gen-rust plugin.
provided by this crate.
When building with cargo, consider using protoc-rust or protobuf-codegen-pure crates.
How to use protoc-gen-rust if you have to
(Note protoc can be invoked programmatically with
protoc crate)
- Install protobuf for protocbinary.
On OS X Homebrew can be used:
brew install protobuf
On Ubuntu, protobuf-compiler package can be installed:
apt-get install protobuf-compiler
Protobuf is needed only for code generation, rust-protobuf runtime
does not use protobuf library.
- Install protoc-gen-rustprogram (which isprotocplugin)
It can be installed either from source or with cargo install protobuf command.
- Add protoc-gen-rustto $PATH
If you installed it with cargo, it should be
PATH="$HOME/.cargo/bin:$PATH"
- Generate .rs files:
protoc --rust_out . foo.proto
This will generate .rs files in current directory.
Version 2
This is documentation for version 2 of the crate.
Version 3 of the crate
(currently in development) encapsulates both protoc and pure codegens in this crate.