tonic-build-extend

Crates.iotonic-build-extend
lib.rstonic-build-extend
version0.1.1
created_at2024-03-04 14:18:38.460182+00
updated_at2025-04-25 04:38:37.072098+00
descriptionextend tonic-build to support multiple types_attributes and fields_attributes
homepagehttps://github.com/yjhtry/tonic-build-extend#readme
repositoryhttps://github.com/yjhtry/tonic-build-extend
max_upload_size
id1161815
size33,476
todoList (yjhtry)

documentation

https://docs.rs/tonic-build-extend

README

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");

}

Commit count: 9

cargo fmt