2 releases

0.1.2 Sep 3, 2020
0.1.1 Jul 20, 2020

#49 in Build Utils

37 downloads per month

Apache-2.0

170KB
4.5K SLoC

API to generate .rs files for ttrpc from protobuf

API to generate .rs files to be used e. g. from build.rs.

Example code:

use ttrpc_codegen::Codegen;
use ttrpc_codegen::Customize;

fn main() {
    Codegen::new()
        .out_dir("protocols/sync")
        .inputs(&protos)
        .include("protocols/protos")
        .rust_protobuf()
        .customize(Customize {
            ..Default::default()
        })
        .run()
        .expect("Gen code failed.");
}

And in Cargo.toml:

[build-dependencies]
ttrpc-codegen = "0.3"

The alternative is to use protoc-rust crate, which relies on protoc command to parse descriptors. Both crates should produce the same result, otherwise please file a bug report.


lib.rs:

API to generate .rs files for ttrpc from protobuf

use ttrpc_codegen::Codegen;
use ttrpc_codegen::Customize;

fn main() {
    Codegen::new()
        .out_dir("protocols/sync")
        .inputs(&protos)
        .include("protocols/protos")
        .rust_protobuf()
        .customize(Customize {
            ..Default::default()
        })
        .run()
        .expect("Gen code failed.");
}

Dependencies

~13MB
~105K SLoC