Switch to prost for protobuf encoding/decoding #176
Merged
+349
−174
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are several things we had to work around with quick-protobuf, like forcing no_std mode to use BTreeMaps and avoiding helper functions to read and write non-size-delimited messages. In addition, the pb-rs code generator doesn't support adding #[derive]s to enums and the existing support for adding derives to structs is broken due to incorrect string concatenation.
Prost doesn't have these limitations and bugs. I originally avoided it because prost_build required the external
protoc
binary, but now that the protox library exists, the code generation can be done entirely in Rust without external tools.Prost also fully supports adding custom attributes to structs, enums, and fields. This will be helpful for future payload unpack and pack commands where the payload manifest would have to be serialized to TOML.
The e2e checksums had to be updated because prost's serialized bytes on the wire differ from quick-protobuf, despite having the same semantic meaning. Since all checksums need to be updated anyway, the Magisk apk and OTA images have all been updated to the latest versions.