| Crates.io | tonic-build-extend |
| lib.rs | tonic-build-extend |
| version | 0.1.1 |
| created_at | 2024-03-04 14:18:38.460182+00 |
| updated_at | 2025-04-25 04:38:37.072098+00 |
| description | extend tonic-build to support multiple types_attributes and fields_attributes |
| homepage | https://github.com/yjhtry/tonic-build-extend#readme |
| repository | https://github.com/yjhtry/tonic-build-extend |
| max_upload_size | |
| id | 1161815 |
| size | 33,476 |
This is a simple example of how to use extended functions of tonic-build.
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");
}