* chore: Add tags to .gitignore
When generating ctags/universal-ctags, a 'tags' file is generated. This
commit adds any generted 'tags' file to .gitignore.
* feat(build): Expose type_attribute and field_attribute
This commit exposes the `type_attribute` and `field_attribute`
configuration settings from Prost. These are useful to tweak/extend the
generated types.
For example:
```
tonic_build::configure()
.out_dir(tmp)
.format(false)
.type_attribute(".", "#[derive(Serialize, Deserialize)]")
.type_attribute(".", "#[serde(rename_all = \"camelCase\")]")
.field_attribute("in", "#[serde(rename = \"in\")]")
.compile(&["tests/protos/wellknown.proto"], &["tests/protos"])
.unwrap();
```
Would add the serde `Serialize` and `Deserialize` traits, while renaming
all the fields to camelCase, and having serde keep fields named `in`
named `in`, rather than Prost's `in_`, to every type generated by Prost.
13 lines
422 B
Rust
13 lines
422 B
Rust
#[test]
|
|
fn wellknown() {
|
|
let tmp = std::env::temp_dir();
|
|
tonic_build::configure()
|
|
.out_dir(tmp)
|
|
.format(false)
|
|
.type_attribute(".", "#[derive(Serialize, Deserialize)]")
|
|
.type_attribute(".", "#[serde(rename_all = \"camelCase\")]")
|
|
.field_attribute("in", "#[serde(rename = \"in\")]")
|
|
.compile(&["tests/protos/wellknown.proto"], &["tests/protos"])
|
|
.unwrap();
|
|
}
|