#codegen #ttrpc #protobuf

ttrpc-codegen

Rust codegen for ttrpc using ttrpc-compiler crate

9 releases

0.4.1 Sep 14, 2022
0.3.2 Oct 14, 2022
0.3.0 Dec 22, 2021
0.2.0 Feb 24, 2021
0.1.1 Jul 20, 2020

#74 in Build Utils

Download history 3646/week @ 2022-08-19 4189/week @ 2022-08-26 3501/week @ 2022-09-02 2920/week @ 2022-09-09 3804/week @ 2022-09-16 5899/week @ 2022-09-23 2935/week @ 2022-09-30 4278/week @ 2022-10-07 5434/week @ 2022-10-14 5042/week @ 2022-10-21 4532/week @ 2022-10-28 5147/week @ 2022-11-04 4854/week @ 2022-11-11 8162/week @ 2022-11-18 6833/week @ 2022-11-25 4927/week @ 2022-12-02

25,844 downloads per month
Used in 2 crates

Apache-2.0

180KB
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

build.rs:

use ttrpc_codegen::Codegen;
use ttrpc_codegen::{Customize, ProtobufCustomize};

fn main() {
    let protos = vec![
        "protos/a.proto",
        "protos/b.proto",
    ];

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

Cargo.toml:

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

Versions

ttrpc-codegen version ttrpc version
0.1.x <= 0.4.x
0.2.x == 0.5.x
0.3.x == 0.6.x
0.4.x >= 0.7.x

Alternative

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.

Dependencies

~7MB
~152K SLoC