Skip to content

Commit

Permalink
added z_bytes_len and z_bytes_is_empty functions; updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Jun 26, 2024
1 parent acc3f59 commit c33bf76
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ Data Structures
.. autoctype:: types.h::zp_send_keep_alive_options_t
.. autoctype:: types.h::zp_send_join_options_t
.. autoctype:: types.h::z_qos_t
.. autoctype:: types.h::z_bytes_iterator_t


Owned Types
~~~~~~~~~~~
Expand Down Expand Up @@ -320,6 +322,11 @@ Primitives
.. autocfunction:: primitives.h::z_bytes_serialize_from_slice_copy
.. autocfunction:: primitives.h::z_bytes_serialize_from_string
.. autocfunction:: primitives.h::z_bytes_serialize_from_string_copy
.. autocfunction:: primitives.h::z_bytes_empty
.. autocfunction:: primitives.h::z_bytes_len
.. autocfunction:: primitives.h::z_bytes_is_empty
.. autocfunction:: primitives.h::z_bytes_get_iterator
.. autocfunction:: primitives.h::z_bytes_iterator_next
.. autocfunction:: primitives.h::z_timestamp_check
.. autocfunction:: primitives.h::z_query_target_default
.. autocfunction:: primitives.h::z_query_consolidation_auto
Expand Down
22 changes: 21 additions & 1 deletion include/zenoh-pico/api/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -844,10 +844,30 @@ z_bytes_iterator_t z_bytes_get_iterator(const z_loaned_bytes_t *bytes);
* iter: An iterator over multi-element serialized data.
* out: An uninitialized :c:type:`z_owned_bytes_t` that will contained next serialized element.
* Return:
* ``false`` when iterator reaches the end, ``true`` otherwise
* ``false`` when iterator reaches the end, ``true`` otherwise.
*/
_Bool z_bytes_iterator_next(z_bytes_iterator_t *iter, z_owned_bytes_t *out);

/**
* Returns total number of bytes in the container.
*
* Parameters:
* bytes: Pointer to a :c:type:`z_loaned_bytes_t` to decode.
* Return:
* Number of bytes in the container.
*/
size_t z_bytes_len(const z_loaned_bytes_t *bytes);

/**
* Checks if container is empty
*
* Parameters:
* bytes: Pointer to a :c:type:`z_loaned_bytes_t` to decode.
* Return:
* ``true`` if conainer is empty, ``false`` otherwise.
*/
_Bool z_bytes_is_empty(const z_loaned_bytes_t *bytes);

/**
* Checks validity of a timestamp
*
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/api/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ _Z_OWNED_TYPE_PTR(_z_bytes_t, bytes)
_Z_LOANED_TYPE(_z_bytes_t, bytes)

/**
* An iterator over multi-element serialized data
* An iterator over multi-element serialized data.
*/
typedef _z_bytes_iterator_t z_bytes_iterator_t;

Expand Down
4 changes: 4 additions & 0 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ int8_t z_bytes_empty(z_owned_bytes_t *bytes) {
return _Z_RES_OK;
}

size_t z_bytes_len(const z_loaned_bytes_t *bytes) { return _z_bytes_len(bytes); }

_Bool z_bytes_is_empty(const z_loaned_bytes_t *bytes) { return _z_bytes_is_empty(bytes); }

z_bytes_iterator_t z_bytes_get_iterator(const z_loaned_bytes_t *bytes) { return _z_bytes_get_iterator(bytes); }

_Bool z_bytes_iterator_next(z_bytes_iterator_t *iter, z_owned_bytes_t *bytes) {
Expand Down

0 comments on commit c33bf76

Please sign in to comment.