Repository navigation
Conversation
Signed-off-by: Michael Ilyin <milyin@gmail.com>
Signed-off-by: Michael Ilyin <milyin@gmail.com>
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.
Add a validated, idiomatic constructor for reconstructing
zenoh::Idfrom decoded bytes. The existinginterop::into_copyable_cpp_obj<Id>(z_id_t)conversion remains available; the new explicitId(const std::array<uint8_t, 16>&, ZResult* = nullptr)constructor provides validation through the usual C++ error convention.The constructor copies the 16 bytes in the same least-significant-byte-first order returned by
bytes(). It rejects all-zero IDs withZ_EINVAL, matching Rust's non-zero ID requirement. With an error pointer, a failed construction leaves a zero placeholder that must not be used as a valid ID. The constructor is documented as unstable, consistent withId. This adds no members and preserves the wrapper's size and alignment.Add
operator!=alongsideoperator==so C++17 callers can compare decoded identities directly, for exampletoken.subject != remote.Universal tests cover byte round trips, source-storage independence, copy/equality/inequality behavior, byte order and boundary values, and zero-ID errors with and without an error pointer. Existing CI automatically builds the new test for both backends.
Validation on macOS: ID tests and strict-warning checks passed with zenoh-c and zenoh-pico, each with exceptions enabled and with
-fno-exceptions. clang-format 18 andgit diff --checkpassed.