commit | 1d5fd76051e7d59d3d6793fb53310f62822a925e | [log] [tgz] |
---|---|---|
author | David Brazdil <dbrazdil@google.com> | Tue Jan 24 18:55:48 2023 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Tue Jan 24 18:55:48 2023 +0000 |
tree | 47ccc947e47deca83a102a1d3b50dac355a6396c | |
parent | 20c810a8b180b347d02e0cc2027a5bd5259ffe3d [diff] | |
parent | 663a35a9636d9b17804b12dd39764dcb7ea805cc [diff] |
Update TEST_MAPPING am: 2ddd49dfd7 am: 23cae9f29d am: 663a35a963 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/protobuf/+/2399422 Change-Id: Ie4e7319e86625a93f350bd5cae6319225b410074 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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.