Repository navigation
Expose sequence length encoding and decoding in C++ - #817
Merged
Merged
Conversation
Signed-off-by: Michael Ilyin <milyin@gmail.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation preserves existing behavior and comprehensively tests the new API contract.
Review effort: Balanced
Findings: None
What changed in this PR
Adds safe sequence-length prefix decoding to the C++ deserialization API.
Changes:
- Exposes
Deserializer::deserialize_sequence_length(). - Reuses it across container deserializers.
- Tests normal, empty, large, missing, and truncated prefixes.
| File | Description |
|---|---|
include/zenoh/api/ext/serialization.hxx |
Adds the API and integrates it with container decoding. |
tests/universal/serialization.cxx |
Covers successful and failing prefix decoding. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Michael Ilyin <milyin@gmail.com>
Signed-off-by: Michael Ilyin <milyin@gmail.com>
DenisBiryukov91
approved these changes
Oct 22, 2026
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.
Applications can now write a sequence prefix with
ext::Serializer::serialize_sequence_length()and read it withext::Deserializer::deserialize_sequence_length(), then process elements individually. Decoders can enforce an application-defined limit before allocating a container.Both methods process only the length prefix and follow the existing
ZResult*/exception convention. With an error pointer, decoding failures return zero and set the result code; a successful empty sequence also returns zero withZ_OK. The serializer caller is responsible for writing the advertised number of elements. Existing container serializers and deserializers reuse these methods. The wire format is unchanged.Tests cover manual sequence encoding compatible with container encoding, sequence elements and a following value, empty sequences, large length-only prefixes, and missing/truncated prefixes. Encoding is exercised with and without an error pointer; malformed prefixes are checked through both decoding error-reporting modes.
Validation
-fno-exceptions, using cached Zetta dependencies. For zenoh-c, unstable APIs were disabled to avoid an unrelated Link API mismatch between the cached dependency and this revision.git diff --checkpassed.