Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add z_encoding_equals #682

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ Primitives
.. autocfunction:: primitives.h::z_encoding_set_schema_from_str
.. autocfunction:: primitives.h::z_encoding_set_schema_from_substr
.. autocfunction:: primitives.h::z_encoding_to_string
.. autocfunction:: primitives.h::z_encoding_equals
.. autocfunction:: primitives.h::z_reply_err_payload
.. autocfunction:: primitives.h::z_reply_err_encoding
.. autocfunction:: primitives.h::z_slice_from_buf
Expand Down
12 changes: 12 additions & 0 deletions include/zenoh-pico/api/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,18 @@ z_result_t z_encoding_set_schema_from_substr(z_loaned_encoding_t *encoding, cons
*/
z_result_t z_encoding_to_string(const z_loaned_encoding_t *encoding, z_owned_string_t *string);

/**
* Checks if 2 encodings are equal.
*
* Parameters:
* left: Pointer to first :c:type:`z_loaned_encoding_t` to compare.
* right: Pointer to second :c:type:`z_loaned_encoding_t` to compare.
*
* Return:
* ``true`` if `left` equals `right`, ``false`` otherwise.
*/
bool z_encoding_equals(const z_loaned_encoding_t *left, const z_loaned_encoding_t *right);

/**
* Gets the bytes data from a reply error payload by aliasing it.
*
Expand Down
4 changes: 4 additions & 0 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ z_result_t z_encoding_to_string(const z_loaned_encoding_t *encoding, z_owned_str
return _Z_RES_OK;
}

bool z_encoding_equals(const z_loaned_encoding_t *left, const z_loaned_encoding_t *right) {
return left->id == right->id && _z_string_equals(&left->schema, &right->schema);
}

z_result_t z_slice_copy_from_buf(z_owned_slice_t *slice, const uint8_t *data, size_t len) {
slice->_val = _z_slice_copy_from_buf(data, len);
if (slice->_val.start == NULL) {
Expand Down
Loading