#protobuf #ttrpc #codegen

ttrpc-codegen

Rust codegen for ttrpc using ttrpc-compiler crate

12 releases

0.4.2 Apr 14, 2023
0.4.1 Sep 14, 2022
0.4.0 Aug 12, 2022
0.3.0 Dec 22, 2021
0.1.1 Jul 20, 2020

#653 in Network programming

Download history 7737/week @ 2024-07-21 8742/week @ 2024-07-28 6790/week @ 2024-08-04 8776/week @ 2024-08-11 6906/week @ 2024-08-18 6719/week @ 2024-08-25 7269/week @ 2024-09-01 7918/week @ 2024-09-08 7152/week @ 2024-09-15 6651/week @ 2024-09-22 7711/week @ 2024-09-29 7927/week @ 2024-10-06 6724/week @ 2024-10-13 8292/week @ 2024-10-20 8134/week @ 2024-10-27 6365/week @ 2024-11-03

30,364 downloads per month
Used in 4 crates (3 directly)

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

~9–19MB
~287K SLoC