#extend #fields-attributes #tonic-build-extend

build tonic-build-extend

extend tonic-build to support multiple types_attributes and fields_attributes

2 releases

new 0.1.1 Apr 25, 2025
0.1.0 Mar 4, 2024

#9 in #extend

Download history 1/week @ 2025-02-23 3/week @ 2025-03-02 1/week @ 2025-03-09 6/week @ 2025-03-16 64/week @ 2025-04-20

64 downloads per month

MIT license

12KB

Tonic-build extend

This is a simple example of how to use extended functions of tonic-build.

Usage

use tonic_build_extend::BuilderExt;

fn main() {
    tonic_build::configure()
        .out_dir("src/pb")
        .types_attributes(
            &[
                "Struct1",
                "Struct2",
            ],
            &[
                "#[derive(derive_builder::Builder)]",
                "#[builder(setter(into), default)]",
            ],
        )
        .fields_attributes(
            &["Struct.fieldName1", "Struct.fieldName2"],
            &["start", "end"],
            &["#[builder(setter(strip_option))]"],
        )
        .compile(&["./protos/pb.proto"], &["protos"])
        .unwrap();

    Command::new("cargo")
        .args(["fmt"])
        .output()
        .expect("Failed to run cargo fmt");

}

Dependencies

~0.6–1MB
~24K SLoC