Skip to content
Rust support for Google protocol buffers
Branch: master
Clone or download
Pull request Compare This branch is 2 commits ahead, 1281 commits behind stepancheg:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Build Status

Protobuf implementation in Rust.

  • Written in pure rust
  • Generate rust code
  • Has runtime library for generated code (Coded{Input|Output}Stream impl)
  • Incomplete and unstable

How to use rust-protobuf

  1. Install protobuf for protoc binary.

On OS X Homebrew can be used:

brew install protobuf

On Ubuntu, protobuf-compiler package can be installed:

apt-get install protobuf-compiler
  1. Compile the project:
cd src

protoc-gen-rust binary is generated. protoc-gen-rust is a rust plugin for protoc.

  1. Add protoc-gen-rust to $PATH:
  1. Generate .rs files:
protoc --rust_out . foo.proto

This will generate .rs files in current directory.

Same procedure is used to regenerate .rs files for rust-protobuf itself, see ./

  1. Include generated files into your project .rs file:
extern mod protobuf; // depend on rust-protobuf runtime
mod foo; // add generated file to the project

Generated code

Have a look at generated files, used internally in rust-protobuf:


  • Implement some rust-specific options
  • Deal better with namespaces
  • Store unknown fields
  • Protobuf reflection
  • Extensions
  • default_instance for messages with repeated fields
  • Generate stubs for services
  • Comprehensive test suite
  • Default value

Contact me

@stepancheg on github if you have any questions, suggesions or patches.

You can’t perform that action at this time.