| commit | 808d2a8f3371210ea88eddd0f86aa7505f7fc749 | [log] [tgz] |
|---|---|---|
| author | David LeGare <legare@google.com> | Mon Mar 07 15:44:34 2022 +0000 |
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Mon Mar 07 15:44:34 2022 +0000 |
| tree | f0d3f05c18afd04b9824b485585518fe06641ee1 | |
| parent | 1ac31f3f997250477bfea60d3c62fecbccdb3206 [diff] | |
| parent | 0af506eab5a6d52635e775e0ad9b6439da826a3a [diff] |
Update TEST_MAPPING am: 9d58b3461e am: ff4f4280e5 am: b339df415e am: 0af506eab5 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/protobuf/+/2004807 Change-Id: I348ea0e1a10743fda99db596d87514259b5867a2
Currently developed branch of rust-protobuf is 3. It has the same spirit as version 2, but contains numerous improvements like:
Stable version of rust-protobuf will be supported until version 3 released.
There are several ways to generate rust code from .proto files
protoc programmatically with protoc-rust crate (recommended)Have a look at readme in protoc-rust crate.
Readme should be in protobuf-codegen-pure crate.
Readme is here.
Have a look at generated files (for current development version), used internally in rust-protobuf:
Rust-protobuf can be used with bytes crate.
To enable Bytes you need to:
with-bytes feature in rust-protobuf:[dependencies] protobuf = { version = "~2.0", features = ["with-bytes"] }
with Customize when codegen is invoked programmatically:
protoc_rust::run(protoc_rust::Args { ... customize: Customize { carllerche_bytes_for_bytes: Some(true), carllerche_bytes_for_string: Some(true), ..Default::default() }, });
or in .proto file:
import "rustproto.proto"; option (rustproto.carllerche_bytes_for_bytes_all) = true; option (rustproto.carllerche_bytes_for_string_all) = true;
With these options enabled, fields of type bytes or string are generated as Bytes or Chars respectively. When CodedInputStream is constructed from Bytes object, fields of these types get subslices of original Bytes object, instead of being allocated on heap.
protoc-rust and protobuf-codegen-pure can be used to rust code from .proto crates.protobuf-codegen for protoc-gen-rust protoc plugin.protoc crate can be used to invoke protoc programmatically.protoc-bin-vendored contains protoc command packed into the crate.