#protobuf #ttrpc #codegen

build ttrpc-codegen

Rust codegen for ttrpc using ttrpc-compiler crate

13 releases

0.5.0 Jan 15, 2025
0.4.2 Apr 14, 2023
0.4.1 Sep 14, 2022
0.3.0 Dec 22, 2021
0.1.1 Jul 20, 2020

#917 in Build Utils

Download history 5412/week @ 2024-12-05 4400/week @ 2024-12-12 4056/week @ 2024-12-19 3313/week @ 2024-12-26 5345/week @ 2025-01-02 5227/week @ 2025-01-09 6567/week @ 2025-01-16 8199/week @ 2025-01-23 6769/week @ 2025-01-30 6959/week @ 2025-02-06 8336/week @ 2025-02-13 10652/week @ 2025-02-20 10377/week @ 2025-02-27 7783/week @ 2025-03-06 7208/week @ 2025-03-13 6364/week @ 2025-03-20

33,805 downloads per month
Used in 6 crates (5 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
0.5.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

~10–20MB
~308K SLoC