Repository navigation
Let the C and Rust clients copy and parse the native payload - #21
Merged
Merged
Conversation
serialize_as_string stays the protobuf transcoding. native_payload is the Phaser buffer itself, so a receiver can load the fields without that step.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The C and Rust clients can now copy and parse the native Phaser payload, the
buffer itself, without going through protobuf wire format.
<prefix>_native_payload(msg), which copiesData()/ByteSizeLong()into aPhaserBytes.<prefix>_parse_native_payload(msg, data, len).It returns 0 and leaves the message unchanged when the bytes are not a
structurally valid Phaser payload. Otherwise it clears the message, takes a
readonly view of the bytes, and
CloneFroms the view into the owned message.native_payload() -> Vec<u8>andparse_native_payload(&[u8]) -> bool.serialize_as_string/parse_from_stringare unchanged. They remain theprotobuf transcoding.
Notes
absolute, and the free-list layout depends on how the message was built. Receivers
must parse fields, not compare bytes.
outlive it. A movable dynamic buffer's process-local resizer pointer is
copied but never dereferenced on the readonly parse or
CloneFrompath,so the bytes are safe to send to another process.
Tests
bazelisk test //phaser/testdata:phaser_rust_test //phaser/testdata:phaser_c_api_testmessage is dropped before parsing.
parse_native_payloadand leavethe message unchanged.
Docs
README.mdandphaser/docs/phaser_user_guide.mddescribe the new methodsand that
serialize_as_stringstays protobuf.