ppsc-build-0.1.0 has been yanked.
Protocol Buffers Parity SCALE Codec Generator
It generates Rust code from source .proto files using the proto2 or proto3 syntax. It's goal is to make the generated code as simple as possible in Parity SCALE Codec fromat.
ppsc-build compiles .proto files into Rust.
ppsc-build is designed to be used for build-time code generation as part of a Cargo build-script.
Usage
Let's create a small library crate, snazzy, that defines a collection of snazzy new items in a protobuf file.
&&
First, add pppsc-build and parity-scale-codec as dependencies to Cargo.toml:
Next, add src/items.proto to the project:
syntax = "proto3";
package snazzy.items;
// A snazzy new shirt!
message Shirt {
// Label sizes
enum Size {
SMALL = 0;
MEDIUM = 1;
LARGE = 2;
}
// The base color
string color = 1;
// The size as stated on the label
Size size = 2;
}
To generate Rust code from items.proto, we use ppsc-build in the crate's build.rs build-script:
use Result;
And finally, in lib.rs, include the generated code:
// Include the `items` module, which is generated from items.proto.
// It is important to maintain the same structure as in the proto.
use items;
/// Returns a large shirt of the specified color
Inspirition
LICENSE
MIT