Protocol Buffers and Rust - example

Mar 31, 2019

A quick basic example of Protocol Buffers and Rust.

Final Example

The final example is found on GitHub here.

Dependencies

Add a dependency to the profobuf crate

[dependencies]
protobuf = "2.4.2"

Build Dependencies

Add a build dependency to the profobuf codegen crate

[build-dependencies]
protobuf-codegen-pure = "2.4.2"

Add the proto files

Add one or more proto file as per the Language Guide.

build.rs

Add a build.rs file, using the basic sample from the codegen readme.

Paying attention to the out_dir, input and includes names/paths.