Skip to content

Commit

Permalink
add z_encoding_equals
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Sep 18, 2024
1 parent cc3e576 commit 4f02159
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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

0 comments on commit 4f02159

Please sign in to comment.