tag | f648ea12111350bc18a63a62935ea572399a4b4b | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Thu Aug 10 20:11:28 2023 -0700 |
object | 654557256191b7445462d18abfc80ae9459379e4 |
Android platform 13.0.0 release 10
commit | 654557256191b7445462d18abfc80ae9459379e4 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Tue Mar 08 02:05:24 2022 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Tue Mar 08 02:05:24 2022 +0000 |
tree | f0d3f05c18afd04b9824b485585518fe06641ee1 | |
parent | c6e248b58bc0927b1a69c56d43a497361ae2e095 [diff] | |
parent | 0af506eab5a6d52635e775e0ad9b6439da826a3a [diff] |
Snap for 8270536 from 0af506eab5a6d52635e775e0ad9b6439da826a3a to tm-release Change-Id: I1afc3e5e65c4576b5c9584ef20cb5bdbf6211d5a
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.