commit | fb6641366c449dc4b7850c6ef00b89306b603fa7 | [log] [tgz] |
---|---|---|
author | Bob Badour <bbadour@google.com> | Fri Mar 31 02:09:26 2023 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri Mar 31 02:09:26 2023 +0000 |
tree | b50a997b739f6671b8dc0e6d8d7402b7d61e47b2 | |
parent | fccf2aec8b5f238379300e294257e0035300dd02 [diff] | |
parent | 792e2bd17abdebad6f3b1c2eaa576595d8fb564f [diff] |
[LSC] Add LOCAL_LICENSE_KINDS to external/rust/crates/protobuf am: c5abb32887 am: b4e8eee760 am: d7a4876c00 am: c09e48776e am: 792e2bd17a Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/protobuf/+/2515635 Change-Id: I23194f6a809fc4c4b4b0c6930058ba09113ac27c 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.