| commit | 158191ed44106548cab90722232f15ef9ee355a4 | [log] [tgz] |
|---|---|---|
| author | Jeff Vander Stoep <jeffv@google.com> | Tue Mar 28 08:00:23 2023 +0200 |
| committer | Jeff Vander Stoep <jeffv@google.com> | Tue Mar 28 08:23:41 2023 +0200 |
| tree | 1f335bdd78b8ed748166610ffd856da2f1130d58 | |
| parent | a389dee962e2e8c9edd01919cb729a85be9dbc83 [diff] |
Introduce libprotobuf_deprecated This temporarily introduces a second copy of protobuf 2.27.1 with soong module name libprotobuf_deprecated. This allows migrating other projects across various git branches to libprotobuf_deprecated one-at-a-time until nothing depends on libprotobuf and we can upgrade that to version 3.2. Bug: 270895633 Test: build Change-Id: Ib5102978651ba4999b4e1d3e225ecdce72dbb3c1
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.