File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -6,3 +6,9 @@ generate rust version ttrpc code from proto files.
66
77- [ Manual Generation] ( https://github.com/containerd/ttrpc-rust#1-generate-with-protoc-command ) uses ttrpc-compiler as a protoc plugin
88- [ Programmatic Generation] ( https://github.com/containerd/ttrpc-rust#2-generate-programmatically ) uses ttrpc-compiler as a rust crate
9+
10+ ## Versions
11+ | ttrpc-compiler version | ttrpc version |
12+ | ------------- | ------------- |
13+ | 0.3.x | <= 0.4.x |
14+ | 0.4.x | >= 0.5.x
Original file line number Diff line number Diff line change 22
33API to generate ` .rs ` files to be used e. g. [ from build.rs] ( ../example/build.rs ) .
44
5- Example code:
5+ ## Example
6+
7+ build.rs:
68
79``` rust
810use ttrpc_codegen :: Codegen ;
9- use ttrpc_codegen :: Customize ;
11+ use ttrpc_codegen :: { Customize , ProtobufCustomize } ;
1012
1113fn main () {
14+ let protos = vec! [
15+ " protos/a.proto" ,
16+ " protos/b.proto" ,
17+ ];
18+
1219 Codegen :: new ()
1320 . out_dir (" protocols/sync" )
1421 . inputs (& protos )
@@ -17,19 +24,29 @@ fn main() {
1724 . customize (Customize {
1825 .. Default :: default ()
1926 })
27+ . rust_protobuf_customize (ProtobufCustomize {
28+ .. Default :: default ()
29+ }
2030 . run ()
2131 . expect (" Gen code failed." );
2232}
2333
2434```
2535
26- And in ` Cargo.toml ` :
36+ Cargo . toml:
2737
2838```
2939[build - dependencies ]
30- ttrpc-codegen = "0.3 "
40+ ttrpc - codegen = " 0.2 "
3141```
3242
43+ ## Versions
44+ | ttrpc - codegen version | ttrpc version |
45+ | ------------- | ------------- |
46+ | 0.1 . x | <= 0.4 . x |
47+ | 0.2 . x | >= 0.5 . x |
48+
49+ ## Alternative
3350The alternative is to use
3451[protoc - rust crate ](https : // github.com/stepancheg/rust-protobuf/tree/master/protoc-rust),
3552which relies on `protoc ` command to parse descriptors . Both crates should produce the same result ,
You can’t perform that action at this time.
0 commit comments