API Reference
Zenoh Types
Enums
-
enum z_whatami_t
Whatami values, defined as a bitmask.
-
enumerator Z_WHATAMI_ROUTER
Bitmask to filter Zenoh routers.
-
enumerator Z_WHATAMI_PEER
Bitmask to filter for Zenoh peers.
-
enumerator Z_WHATAMI_CLIENT
Bitmask to filter for Zenoh clients.
-
enumerator Z_WHATAMI_ROUTER
-
enum zp_keyexpr_canon_status_t
Status values for keyexpr canonization operation. Used as return value of canonization-related functions, like
z_keyexpr_is_canon()orz_keyexpr_canonize().-
enumerator Z_KEYEXPR_CANON_SUCCESS
The key expression is canon.
-
enumerator Z_KEYEXPR_CANON_LONE_DOLLAR_STAR
The key contains a
$*chunk, which must be replaced by*.
-
enumerator Z_KEYEXPR_CANON_SINGLE_STAR_AFTER_DOUBLE_STAR
The key contains
** / *, which must be replaced by* / **.
-
enumerator Z_KEYEXPR_CANON_DOUBLE_STAR_AFTER_DOUBLE_STAR
The key contains
** / **, which must be replaced by**.
-
enumerator Z_KEYEXPR_CANON_EMPTY_CHUNK
The key contains empty chunks.
-
enumerator Z_KEYEXPR_CANON_STARS_IN_CHUNK
The key contains a
*in a chunk without being escaped by a DSL, which is forbidden.
-
enumerator Z_KEYEXPR_CANON_DOLLAR_AFTER_DOLLAR_OR_STAR
The key contains
$*$or$$, which is forbidden.
-
enumerator Z_KEYEXPR_CANON_CONTAINS_SHARP_OR_QMARK
The key contains
#or?, which is forbidden.
-
enumerator Z_KEYEXPR_CANON_CONTAINS_UNBOUND_DOLLAR
The key contains a
$which is not bound to a DSL.
-
enumerator Z_KEYEXPR_CANON_SUCCESS
-
enum z_sample_kind_t
Sample kind values.
-
enumerator Z_SAMPLE_KIND_PUT
The Sample was issued by a
putoperation.
-
enumerator Z_SAMPLE_KIND_DELETE
The Sample was issued by a
deleteoperation.
-
enumerator Z_SAMPLE_KIND_PUT
-
enum z_encoding_id_t
Default encoding values used by Zenoh.
An encoding has a similar role to Content-type in HTTP: it indicates, when present, how data should be interpreted by the application.
Please note the Zenoh protocol does not impose any encoding value nor it operates on it. It can be seen as some optional metadata that is carried over by Zenoh in such a way the application may perform different operations depending on the encoding value.
A set of associated constants are provided to cover the most common encodings for user convenience. This is particularly useful in helping Zenoh to perform additional network optimizations.
-
enum z_consolidation_mode_t
Consolidation mode values.
-
enumerator Z_CONSOLIDATION_MODE_AUTO
Let Zenoh decide the best consolidation mode depending on the query selector.
-
enumerator Z_CONSOLIDATION_MODE_NONE
No consolidation is applied. Replies may come in any order and any number.
-
enumerator Z_CONSOLIDATION_MODE_MONOTONIC
It guarantees that any reply for a given key expression will be monotonic in time w.r.t. the previous received replies for the same key expression. I.e., for the same key expression multiple replies may be received. It is guaranteed that two replies received at t1 and t2 will have timestamp ts2 > ts1. It optimizes latency.
-
enumerator Z_CONSOLIDATION_MODE_LATEST
It guarantees unicity of replies for the same key expression. It optimizes bandwidth.
-
enumerator Z_CONSOLIDATION_MODE_AUTO
-
enum z_reliability_t
Reliability values.
-
enumerator Z_RELIABILITY_BEST_EFFORT
Defines reliability as
BEST_EFFORT
-
enumerator Z_RELIABILITY_RELIABLE
Defines reliability as
RELIABLE
-
enumerator Z_RELIABILITY_BEST_EFFORT
-
enum z_reply_tag_t
Reply tag values.
-
enumerator Z_REPLY_TAG_DATA
Tag identifying that the reply contains some data.
-
enumerator Z_REPLY_TAG_FINAL
Tag identifying that the reply does not contain any data and that there will be no more replies for this query.
-
enumerator Z_REPLY_TAG_DATA
-
enum z_congestion_control_t
Congestion control values.
-
enumerator Z_CONGESTION_CONTROL_BLOCK
Defines congestion control as
BLOCK. Messages are not dropped in case of congestion control.
-
enumerator Z_CONGESTION_CONTROL_DROP
Defines congestion control as
DROP. Messages are dropped in case of congestion control.
-
enumerator Z_CONGESTION_CONTROL_BLOCK
-
enum z_priority_t
Priority of Zenoh messages values.
-
enumerator _Z_PRIORITY_CONTROL
Priority for
Controlmessages.
-
enumerator Z_PRIORITY_REAL_TIME
Priority for
RealTimemessages.
-
enumerator Z_PRIORITY_INTERACTIVE_HIGH
Highest priority for
Interactivemessages.
-
enumerator Z_PRIORITY_INTERACTIVE_LOW
Lowest priority for
Interactivemessages.
-
enumerator Z_PRIORITY_DATA_HIGH
Highest priority for
Datamessages.
-
enumerator Z_PRIORITY_DATA
Default priority for
Datamessages.
-
enumerator Z_PRIORITY_DATA_LOW
Lowest priority for
Datamessages.
-
enumerator Z_PRIORITY_BACKGROUND
Priority for
Background trafficmessages.
-
enumerator _Z_PRIORITY_CONTROL
Data Structures
-
typedef int z_zint_t
Represents a variable-length encoding unsigned integer.
It is equivalent to the size of a
size_t.
-
typedef int z_id_t
Represents a Zenoh ID.
In general, valid Zenoh IDs are LSB-first 128bit unsigned and non-zero integers.
-
uint8_t id[16]
The array containing the 16 octets of a Zenoh ID.
-
uint8_t id[16]
-
typedef int z_timestamp_t
-
type z_subscriber_options_t
Represents the configuration used to configure a subscriber upon declaration
z_declare_subscriber().-
z_reliability_t reliability
The subscription reliability value.
-
z_reliability_t reliability
-
type z_query_consolidation_t
Represents the reply consolidation mode to apply on replies to a
z_get().-
z_consolidation_mode_t mode
the consolidation mode, see
z_consolidation_mode_t
-
z_consolidation_mode_t mode
-
type z_publisher_options_t
Represents the configuration used to configure a publisher upon declaration with
z_declare_publisher().-
z_congestion_control_t congestion_control
The congestion control to apply when routing messages from this
- publisher.
z_priority_t priority: The priority of messages issued by this publisher.
-
z_congestion_control_t congestion_control
-
type z_queryable_options_t
Represents the configuration used to configure a queryable upon declaration
z_declare_queryable().-
_Bool complete
The completeness of the queryable.
-
_Bool complete
-
type z_query_reply_options_t
Represents the configuration used to configure a query reply sent via :c:func:`z_query_reply.
-
z_owned_encoding_t *encoding
The encoding of the payload.
-
z_owned_bytes_t *attachment
An optional attachment to the response.
-
z_owned_encoding_t *encoding
-
type z_put_options_t
Represents the configuration used to configure a put operation sent via via
z_put().-
z_owned_encoding_t *encoding
The encoding of the payload.
-
z_congestion_control_t congestion_control
The congestion control to apply when routing this message.
-
z_priority_t priority
The priority of this message when routed.
-
z_owned_bytes_t *attachment
An optional attachment to the publication.
-
z_owned_encoding_t *encoding
-
type z_delete_options_t
Represents the configuration used to configure a delete operation sent via
z_delete().-
z_congestion_control_t congestion_control
The congestion control to apply when routing this message.
-
z_priority_t priority
The priority of this message when router.
-
z_congestion_control_t congestion_control
-
type z_publisher_put_options_t
Represents the configuration used to configure a put operation by a previously declared publisher, sent via
z_publisher_put().-
z_owned_encoding_t *encoding
The encoding of the payload.
-
z_owned_bytes_t *attachment
An optional attachment to the publication.
-
z_owned_encoding_t *encoding
-
type z_publisher_delete_options_t
Represents the configuration used to configure a delete operation by a previously declared publisher, sent via
z_publisher_delete().
-
type z_get_options_t
Represents the configuration used to configure a get operation sent via
z_get().-
z_owned_bytes_t payload
The payload to include in the query.
-
z_owned_encoding_t *encoding
Payload encoding.
-
z_query_consolidation_t consolidation
The replies consolidation strategy to apply on replies.
-
z_query_target_t target
The queryables that should be targeted by this get.
-
z_owned_bytes_t *attachment
An optional attachment to the query.
-
z_owned_bytes_t payload
-
type zp_task_read_options_t
Represents the configuration used to configure a read task started via
zp_start_read_task().
-
type zp_task_lease_options_t
Represents the configuration used to configure a lease task started via
zp_start_lease_task().
-
type zp_read_options_t
Represents the configuration used to configure a read operation started via
zp_read().
-
type zp_send_keep_alive_options_t
Represents the configuration used to configure a send keep alive operation started via
zp_send_keep_alive().
-
type zp_send_join_options_t
Represents the configuration used to configure a send join operation started via
zp_send_join().
-
typedef int z_qos_t
QoS settings of a zenoh message.
Owned Types
TODO: owned type description
-
type z_owned_slice_t
Represents an array of bytes.
-
type z_owned_bytes_t
Represents an array of bytes container.
-
type z_owned_string_t
Represents a string without null-terminator.
-
type z_owned_keyexpr_t
Represents a key expression in Zenoh.
-
type z_owned_config_t
Represents a Zenoh configuration, used to configure Zenoh sessions upon opening.
-
type z_owned_scouting_config_t
Represents a scouting configuration, used to configure a scouting procedure.
-
type z_owned_session_t
Represents a Zenoh Session.
-
type z_owned_subscriber_t
Represents a Zenoh Subscriber entity.
-
type z_owned_publisher_t
Represents a Zenoh Publisher entity.
-
type z_owned_queryable_t
Represents a Zenoh Queryable entity.
-
type z_owned_query_t
Represents a Zenoh Query entity, received by Zenoh queryable entities.
-
type z_owned_encoding_t
Represents the encoding of a payload, in a MIME-like format.
-
type z_owned_reply_err_t
Represents a Zenoh reply error value.
-
type z_owned_sample_t
Represents a data sample.
-
type z_owned_hello_t
Represents the content of a hello message returned by a zenoh entity as a reply to a scout message.
-
type z_owned_reply_t
Represents the reply to a query.
-
type z_owned_string_array_t
Represents an array of non null-terminated string.
Loaned Types
TODO: loaned type description
-
type z_loaned_slice_t
Represents an array of bytes.
-
type z_loaned_bytes_t
Represents an array of bytes container.
-
type z_loaned_string_t
Represents a string without null-terminator.
-
type z_loaned_keyexpr_t
Represents a key expression in Zenoh.
-
type z_loaned_config_t
Represents a Zenoh configuration, used to configure Zenoh sessions upon opening.
-
type z_loaned_scouting_config_t
Represents a scouting configuration, used to configure a scouting procedure.
-
type z_loaned_session_t
Represents a Zenoh Session.
-
type z_loaned_subscriber_t
Represents a Zenoh Subscriber entity.
-
type z_loaned_publisher_t
Represents a Zenoh Publisher entity.
-
type z_loaned_queryable_t
Represents a Zenoh Queryable entity.
-
type z_loaned_query_t
Represents a Zenoh Query entity, received by Zenoh queryable entities.
-
type z_loaned_encoding_t
Represents the encoding of a payload, in a MIME-like format.
-
type z_loaned_reply_err_t
Represents a Zenoh reply error.
-
type z_loaned_sample_t
Represents a data sample.
-
type z_loaned_hello_t
Represents the content of a hello message returned by a zenoh entity as a reply to a scout message.
-
type z_loaned_reply_t
Represents the reply to a query.
-
type z_loaned_string_array_t
Represents an array of non null-terminated string.
View Types
TODO: view type description
-
type z_view_string_t
Represents a string without null-terminator.
-
type z_view_keyexpr_t
Represents a key expression in Zenoh.
-
type z_view_string_array_t
Represents an array of non null-terminated string.
Closures
- A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks:
context: a pointer to an arbitrary state.
call: the typical callback function.
contextwill be passed as its last argument.drop: allows the callback’s state to be freed.
contextwill be passed as its last argument.
Closures are not guaranteed not to be called concurrently.
- It is guaranteed that:
callwill never be called oncedrophas started.dropwill only be called once, and after everycallhas ended.The two previous guarantees imply that
callanddropare never called concurrently.
-
type z_owned_closure_sample_t
Represents the sample closure.
A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks.
-
void *context
a pointer to an arbitrary state.
-
z_data_handler_t call
void *call(const struct z_sample_t*, const void *context) is the callback function.
-
z_dropper_handler_t drop
void *drop(void*) allows the callback’s state to be freed.
-
void *context
-
type z_owned_closure_query_t
Represents the query callback closure.
A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks.
-
void *context
a pointer to an arbitrary state.
-
_z_queryable_handler_t call
void (*_z_queryable_handler_t)(z_query_t *query, void *arg) is the
- callback function.
z_dropper_handler_t drop: void *drop(void*) allows the callback’s state to be freed. void *context: a pointer to an arbitrary state.
-
void *context
-
type z_owned_closure_reply_t
Represents the query reply callback closure.
A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks.
-
void *context
a pointer to an arbitrary state.
-
z_reply_handler_t call
void (*_z_reply_handler_t)(_z_reply_t *reply, void *arg) is the
- callback function.
z_dropper_handler_t drop: void *drop(void*) allows the callback’s state to be freed. void *context: a pointer to an arbitrary state.
-
void *context
-
type z_owned_closure_hello_t
Represents the Zenoh ID callback closure.
A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks.
-
void *context
a pointer to an arbitrary state.
-
z_loaned_hello_handler_t call
void (*z_loaned_hello_handler_t)(const z_loaned_hello_t *hello, void *arg) is the
- callback function.
z_dropper_handler_t drop: void *drop(void*) allows the callback’s state to be freed. void *context: a pointer to an arbitrary state.
-
void *context
-
type z_owned_closure_zid_t
Represents the Zenoh ID callback closure.
A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks.
-
void *context
a pointer to an arbitrary state.
a pointer to an arbitrary state.
-
z_id_handler_t call
void (*z_id_handler_t)(const z_id_t *id, void *arg) is the callback function.
-
z_dropper_handler_t drop
void *drop(void*) allows the callback’s state to be freed.
-
void *context
Zenoh Functions
Macros
-
z_loan(x)
-
z_move(x)
Defines a generic function for moving any of the
z_owned_X_ttypes.- Parameters:
x – The instance to move.
- Returns:
Returns the instance associated with x.
-
z_check(x)
-
z_clone(x)
Defines a generic function for cloning any of the
z_owned_X_ttypes.- Parameters:
x – The instance to clone.
- Returns:
Returns the cloned instance of x.
-
z_drop(x)
Defines a generic function for dropping any of the
z_owned_X_ttypes.- Parameters:
x – The instance to drop.
-
z_closure()
Defines a variadic macro to ease the definition of callback closures.
- Parameters:
callback – the typical
callbackfunction.contextwill be passed as its last argument.dropper – allows the callback’s state to be freed.
contextwill be passed as its last argument.context – a pointer to an arbitrary state.
- Returns:
Returns the new closure.
-
z_null(x)
Defines a generic function for making null object of any of the
z_owned_X_ttypes.- Returns:
Returns the uninitialized instance of x.
Primitives
-
int8_t z_view_string_wrap(z_view_string_t *str, const char *value)
Data Types Handlers
Builds a
z_view_string_tby wrapping aconst char *string.- Parameters:
value – Pointer to a null terminated string.
str – Pointer to an uninitialized
z_view_string_t.
- Returns:
0if creation successful,negative valueotherwise.
-
int8_t z_view_keyexpr_from_string(z_view_keyexpr_t *keyexpr, const char *name)
Builds a
z_keyexpr_tfrom a null-terminated string. It is a loaned key expression that aliasesname. Unlike it’s counterpart in zenoh-c, this function does not test passed expression to correctness.- Parameters:
name – Pointer to string representation of the keyexpr as a null terminated string.
keyexpr – Pointer to an uninitialized
z_view_keyexpr_t.
- Returns:
0if creation successful,negative valueotherwise.
-
int8_t z_view_keyexpr_from_string_unchecked(z_view_keyexpr_t *keyexpr, const char *name)
Builds a
z_keyexpr_tfrom a null-terminated string. It is a loaned key expression that aliasesname. Input key expression is not checked for correctness.- Parameters:
name – Pointer to string representation of the keyexpr as a null terminated string.
keyexpr – Pointer to an uninitialized
z_view_keyexpr_t.
- Returns:
0if creation successful,negative valueotherwise.
-
int8_t z_keyexpr_to_string(const z_loaned_keyexpr_t *keyexpr, z_owned_string_t *str)
Gets a null-terminated string from a
z_keyexpr_t.If given keyexpr contains a declared keyexpr, the resulting owned string will be uninitialized. In that case, the user must use
zp_keyexpr_resolve()to resolve the nesting declarations and get its full expanded representation.- Parameters:
keyexpr – Pointer to a loaned instance of
z_keyexpr_t.str – Pointer to an uninitialized
z_owned_string_t.
- Returns:
0if creation successful,negative valueotherwise.
-
int8_t zp_keyexpr_resolve(const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr, z_owned_string_t *str)
Builds a null-terminated string from a
z_loaned_keyexpr_tfor a givenz_loaned_session_t.- Parameters:
zs – Pointer to a
z_loaned_session_tto resolve the keyexpr.keyexpr – Pointer to a
z_loaned_keyexpr_tto be resolved.str – Pointer to an uninitialized
z_owned_string_t.
- Returns:
0if creation successful,negative valueotherwise.
-
_Bool z_keyexpr_is_initialized(const z_loaned_keyexpr_t *keyexpr)
Checks if a given keyexpr is valid.
- Parameters:
keyexpr – Pointer to a
z_loaned_keyexpr_tto be checked.
- Returns:
trueif keyexpr is valid, orfalseotherwise.
-
int8_t z_keyexpr_is_canon(const char *start, size_t len)
Checks if a given keyexpr is valid and in canonical form.
- Parameters:
start – Pointer to the keyexpr in its string representation as a non-null terminated string.
len – Number of characters in
start.
- Returns:
0if passed string is a valid (and canon) key expression, or anegative valueotherwise. Error codes are defined inzp_keyexpr_canon_status_t.
-
int8_t zp_keyexpr_is_canon_null_terminated(const char *start)
Checks if a given keyexpr is valid and in canonical form.
- Parameters:
start – Pointer to the keyexpr in its string representation as a null terminated string.
len – Number of characters in
start.
- Returns:
0if passed string is a valid (and canon) key expression, or anegative valueotherwise. Error codes are defined inzp_keyexpr_canon_status_t.
-
int8_t z_keyexpr_canonize(char *start, size_t *len)
Canonizes of a given keyexpr in string representation. The canonization is performed over the passed string, possibly shortening it by modifying
len.- Parameters:
start – Pointer to the keyexpr in its string representation as a non-null terminated string.
len – Number of characters in
start.
- Returns:
0if canonization successful, or anegative valueotherwise. Error codes are defined inzp_keyexpr_canon_status_t.
-
int8_t zp_keyexpr_canonize_null_terminated(char *start)
Canonizes a given keyexpr in string representation. The canonization is performed over the passed string, possibly shortening it by modifying
len.- Parameters:
start – Pointer to the keyexpr in its string representation as a null terminated string.
len – Number of characters in
start.
- Returns:
0if canonization successful, or anegative valueotherwise. Error codes are defined inzp_keyexpr_canon_status_t.
-
_Bool z_keyexpr_includes(const z_loaned_keyexpr_t *l, const z_loaned_keyexpr_t *r)
Checks if a given keyexpr contains another keyexpr in its set.
- Parameters:
l – Pointer to a
z_loaned_keyexpr_t.r – Pointer to a
z_loaned_keyexpr_t.
- Returns:
trueiflincludesr, i.e. the set defined bylcontains every key belonging to the set
defined by
r. Otherwise, returnsfalse.
-
_Bool zp_keyexpr_includes_null_terminated(const char *l, const char *r)
Checks if a given keyexpr contains another keyexpr in its set.
- Parameters:
l – Pointer to the keyexpr in its string representation as a null terminated string.
llen – Number of characters in
l.r – Pointer to the keyexpr in its string representation as a null terminated string.
rlen – Number of characters in
r.
- Returns:
trueiflincludesr, i.e. the set defined bylcontains every key belonging to the set
defined by
r. Otherwise, returnsfalse.
-
_Bool z_keyexpr_intersects(const z_loaned_keyexpr_t *l, const z_loaned_keyexpr_t *r)
Checks if a given keyexpr intersects with another keyexpr.
- Parameters:
l – Pointer to a
z_loaned_keyexpr_t.r – Pointer to a
z_loaned_keyexpr_t.
- Returns:
trueif keyexprs intersect, i.e. there exists at least one key which is contained in both of the
sets defined by
landr. Otherwise, returnsfalse.
-
_Bool zp_keyexpr_intersect_null_terminated(const char *l, const char *r)
Checks if a given keyexpr intersects with another keyexpr.
- Parameters:
l – Pointer to the keyexpr in its string representation as a null terminated string.
llen – Number of characters in
l.r – Pointer to the keyexpr in its string representation as a null terminated string.
rlen – Number of characters in
r.
- Returns:
trueif keyexprs intersect, i.e. there exists at least one key which is contained in both of the
sets defined by
landr. Otherwise, returnsfalse.
-
_Bool z_keyexpr_equals(const z_loaned_keyexpr_t *l, const z_loaned_keyexpr_t *r)
Checks if two keyexpr are equal.
- Parameters:
l – Pointer to a
z_loaned_keyexpr_t.r – Pointer to a
z_loaned_keyexpr_t.
- Returns:
trueif bothlandrare equal. Otherwise, returnsfalse.
-
_Bool zp_keyexpr_equals_null_terminated(const char *l, const char *r)
Checks if two keyexpr as null terminated string are equal.
- Parameters:
l – Pointer to the keyexpr in its string representation as a null terminated string.
llen – Number of characters in
l.r – Pointer to the keyexpr in its string representation as a null terminated string.
rlen – Number of characters in
r.
- Returns:
trueif bothlandrare equal. Otherwise, it returnsfalse.
-
void z_config_new(z_owned_config_t *config)
Builds a new, zenoh-allocated, empty configuration. It consists in an empty set of properties for zenoh session configuration.
- Parameters:
config – Pointer to uninitialized
z_owned_config_t.
-
void z_config_default(z_owned_config_t *config)
Builds a new, zenoh-allocated, default configuration. It consists in a default set of properties for zenoh session configuration.
- Parameters:
config – Pointer to uninitialized
z_owned_config_t.
-
const char *zp_config_get(const z_loaned_config_t *config, uint8_t key)
Gets the property with the given integer key from the configuration.
- Parameters:
config – Pointer to a
z_loaned_config_tto get the property from.key – Integer key of the requested property.
- Returns:
The requested property value.
-
int8_t zp_config_insert(z_loaned_config_t *config, uint8_t key, const char *value)
Inserts or replaces the property with the given integer key in the configuration.
- Parameters:
config – Pointer to a
z_loaned_config_tto modify.key – Integer key of the property to be inserted.
value – Property value to be inserted.
- Returns:
0if insertion successful,negative valueotherwise.
-
void z_scouting_config_default(z_owned_scouting_config_t *sc)
Builds a new
z_owned_scouting_config_twith a default set of properties for scouting configuration.- Parameters:
sc – Pointer to an uninitialized
z_owned_scouting_config_t.
-
int8_t z_scouting_config_from(z_owned_scouting_config_t *sc, const z_loaned_config_t *config)
Builds a new
z_owned_scouting_config_twith values from az_loaned_config_t.- Parameters:
config – Pointer to a
z_owned_config_tto get the values from.sc – Pointer to an uninitialized
z_owned_scouting_config_t.
- Returns:
0if build successful,negative valueotherwise.
-
const char *zp_scouting_config_get(const z_loaned_scouting_config_t *config, uint8_t key)
Gets the property with the given integer key from the configuration.
- Parameters:
config – Pointer to a
z_loaned_scouting_config_tto get the property from.key – Integer key for the requested property.
- Returns:
The requested property value.
-
int8_t zp_scouting_config_insert(z_loaned_scouting_config_t *config, uint8_t key, const char *value)
Inserts or replace the property with the given integer key in the configuration.
- Parameters:
config – Pointer to a
z_loaned_scouting_config_tto modify.key – Integer key for the property to be inserted.
value – Property value to be inserted.
- Returns:
0if insertion successful,negative valueotherwise.
-
int8_t zp_encoding_make(z_owned_encoding_t *encoding, z_encoding_id_t id, const char *schema)
Builds a new
z_owned_encoding_t.- Parameters:
encoding – Pointer to an uninitialized
z_owned_encoding_t.id – A known
z_encoding_id_tvalue.schema – Pointer to a custom schema string value.
- Returns:
0if creation successful,negative valueotherwise.
-
int8_t zp_encoding_default(z_owned_encoding_t *encoding)
Builds a new a
z_owned_encoding_twith default value.- Parameters:
encoding – Pointer to an uninitialized
z_owned_encoding_t.
- Returns:
0if creation successful,negative valueotherwise.
-
_Bool z_encoding_check(const z_owned_encoding_t *encoding)
Checks if a
z_owned_encoding_thas non-default values.- Returns:
trueif encoding is in non-default state,falseotherwise.
-
void z_encoding_drop(z_owned_encoding_t *encoding)
Free the memory of a
z_owned_encoding_t.
-
const z_loaned_encoding_t *z_encoding_loan(const z_owned_encoding_t *encoding)
Gets a loaned version of a
z_owned_encoding_t.- Parameters:
encoding – Pointer to a
z_owned_encoding_tto loan.
- Returns:
Pointer to the loaned version.
-
z_loaned_encoding_t *z_encoding_loan_mut(z_owned_encoding_t *encoding)
Gets a loaned version of a
z_owned_encoding_t.- Parameters:
encoding – Pointer to a
z_owned_encoding_tto loan.
- Returns:
Pointer to the loaned version.
-
z_owned_encoding_t *z_encoding_move(z_owned_encoding_t *encoding)
Gets a moved version of a
z_owned_encoding_t.- Parameters:
encoding – Pointer to a
z_owned_encoding_tto move.
- Returns:
Pointer to the moved version.
-
int8_t z_encoding_null(z_owned_encoding_t *encoding)
Builds a
z_owned_encoding_twith default value.- Parameters:
encoding – Pointer to an uninitialized
z_owned_encoding_t.
- Returns:
0if creation successful,``negative value`` otherwise.
-
const z_loaned_bytes_t *z_reply_err_payload(const z_loaned_reply_err_t *reply_err)
Gets the bytes data from a reply error payload by aliasing it.
- Parameters:
reply_err – Pointer to a
z_loaned_reply_err_tto get data from.
- Returns:
Pointer to the data as a
z_loaned_bytes_t.
-
const z_loaned_encoding_t *z_reply_err_encoding(const z_loaned_reply_err_t *reply_err)
Gets a reply error encoding by aliasing it.
- Parameters:
query – Pointer to the
z_loaned_reply_err_tto get the encoding from.
- Returns:
Pointer to the encoding as a
z_loaned_encoding_t.
-
const uint8_t *z_slice_data(const z_loaned_slice_t *slice)
Gets date pointer of a bytes array.
- Parameters:
slice – Pointer to a
z_loaned_slice_tto get data from.
- Returns:
The data pointer.
-
size_t z_slice_len(const z_loaned_slice_t *slice)
Gets total number of bytes in a bytes array.
- Parameters:
slice – Pointer to a
z_loaned_slice_tto get length from.
- Returns:
The number of bytes.
-
int8_t z_bytes_deserialize_into_int8(const z_loaned_bytes_t *bytes, int8_t *dst)
Decodes data into a int8_t signed integer.
- Parameters:
bytes – Pointer to a
z_loaned_bytes_tto decode.dst – Pointer to an uninitialized
int8_tto contain the decoded int.
- Returns:
0if decode successful, or anegative valueotherwise.
-
int8_t z_bytes_deserialize_into_int16(const z_loaned_bytes_t *bytes, int16_t *dst)
Decodes data into a int16_t signed integer.
- Parameters:
bytes – Pointer to a
z_loaned_bytes_tto decode.dst – Pointer to an uninitialized
int16_tto contain the decoded int.
- Returns:
0if decode successful, or anegative valueotherwise.
-
int8_t z_bytes_deserialize_into_int32(const z_loaned_bytes_t *bytes, int32_t *dst)
Decodes data into a int32_t signed integer.
- Parameters:
bytes – Pointer to a
z_loaned_bytes_tto decode.dst – Pointer to an uninitialized
int32_tto contain the decoded int.
- Returns:
0if decode successful, or anegative valueotherwise.
-
int8_t z_bytes_deserialize_into_int64(const z_loaned_bytes_t *bytes, int64_t *dst)
Decodes data into a int64_t signed integer.
- Parameters:
bytes – Pointer to a
z_loaned_bytes_tto decode.dst – Pointer to an uninitialized
int64_tto contain the decoded int.
- Returns:
0if decode successful, or anegative valueotherwise.
-
int8_t z_bytes_deserialize_into_uint8(const z_loaned_bytes_t *bytes, uint8_t *dst)
Decodes data into a uint8_t unsigned integer.
- Parameters:
bytes – Pointer to a
z_loaned_bytes_tto decode.dst – Pointer to an uninitialized
uint8_tto contain the decoded int.
- Returns:
0if decode successful, or anegative valueotherwise.
-
int8_t z_bytes_deserialize_into_uint16(const z_loaned_bytes_t *bytes, uint16_t *dst)
Decodes data into a uint16_t unsigned integer.
- Parameters:
bytes – Pointer to a
z_loaned_bytes_tto decode.dst – Pointer to an uninitialized
uint16_tto contain the decoded int.
- Returns:
0if decode successful, or anegative valueotherwise.
-
int8_t z_bytes_deserialize_into_uint32(const z_loaned_bytes_t *bytes, uint32_t *dst)
Decodes data into a uint32_t unsigned integer.
- Parameters:
bytes – Pointer to a
z_loaned_bytes_tto decode.dst – Pointer to an uninitialized
uint32_tto contain the decoded int.
- Returns:
0if decode successful, or anegative valueotherwise.
-
int8_t z_bytes_deserialize_into_uint64(const z_loaned_bytes_t *bytes, uint64_t *dst)
Decodes data into a uint64_t unsigned integer.
- Parameters:
bytes – Pointer to a
z_loaned_bytes_tto decode.dst – Pointer to an uninitialized
uint64_tto contain the decoded int.
- Returns:
0if decode successful, or anegative valueotherwise.
-
int8_t z_bytes_deserialize_into_float(const z_loaned_bytes_t *bytes, float *dst)
Decodes data into a float floating number.
- Parameters:
bytes – Pointer to a
z_loaned_bytes_tto decode.dst – Pointer to an uninitialized
floatto contain the decoded float.
- Returns:
0if decode successful, or anegative valueotherwise.
-
int8_t z_bytes_deserialize_into_double(const z_loaned_bytes_t *bytes, double *dst)
Decodes data into a double floating number.
- Parameters:
bytes – Pointer to a
z_loaned_bytes_tto decode.dst – Pointer to an uninitialized
doubleto contain the decoded float.
- Returns:
0if decode successful, or anegative valueotherwise.
-
int8_t z_bytes_deserialize_into_slice(const z_loaned_bytes_t *bytes, z_owned_slice_t *dst)
Decodes data into a
z_owned_slice_t- Parameters:
bytes – Pointer to a
z_loaned_bytes_tto decode.str – Pointer to an uninitialized
z_owned_slice_tto contain the decoded slice.
- Returns:
0if decode successful, or anegative valueotherwise.
-
int8_t z_bytes_deserialize_into_string(const z_loaned_bytes_t *bytes, z_owned_string_t *str)
Decodes data into a
z_owned_string_t- Parameters:
bytes – Pointer to a
z_loaned_bytes_tto decode.str – Pointer to an uninitialized
z_owned_string_tto contain the decoded string.
- Returns:
0if decode successful, or anegative valueotherwise.
-
int8_t z_bytes_serialize_from_int8(z_owned_bytes_t *bytes, int8_t val)
Encodes a signed integer into a
z_owned_bytes_t- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded int.val – int8_t value to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_int16(z_owned_bytes_t *bytes, int16_t val)
Encodes a signed integer into a
z_owned_bytes_t- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded int.val – int16_t value to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_int32(z_owned_bytes_t *bytes, int32_t val)
Encodes a signed integer into a
z_owned_bytes_t- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded int.val – int32_t value to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_int64(z_owned_bytes_t *bytes, int64_t val)
Encodes a signed integer into a
z_owned_bytes_t- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded int.val – int64_t value to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_uint8(z_owned_bytes_t *bytes, uint8_t val)
Encodes an unsigned integer into a
z_owned_bytes_t- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded int.val – uint8_t value to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_uint16(z_owned_bytes_t *bytes, uint16_t val)
Encodes an unsigned integer into a
z_owned_bytes_t- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded int.val – uint16_t value to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_uint32(z_owned_bytes_t *bytes, uint32_t val)
Encodes an unsigned integer into a
z_owned_bytes_t- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded int.val – uint32_t value to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_uint64(z_owned_bytes_t *bytes, uint64_t val)
Encodes an unsigned integer into a
z_owned_bytes_t- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded int.val – uint64_t value to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_float(z_owned_bytes_t *bytes, float val)
Encodes a floating number into a
z_owned_bytes_t- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded int.val – float value to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_double(z_owned_bytes_t *bytes, double val)
Encodes a floating number into a
z_owned_bytes_t- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded int.val – double value to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_slice(z_owned_bytes_t *bytes, const uint8_t *data, size_t len)
Encodes a slice into a
z_owned_bytes_tby aliasing- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded slice.str – Pointer to the slice to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_slice_copy(z_owned_bytes_t *bytes, const uint8_t *data, size_t len)
Encodes a slice into a
z_owned_bytes_tby copying- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded slice.str – Pointer to the slice to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_string(z_owned_bytes_t *bytes, const char *s)
Encodes a string into a
z_owned_bytes_tby aliasing- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded string.s – Pointer to the string to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
int8_t z_bytes_serialize_from_string_copy(z_owned_bytes_t *bytes, const char *s)
Encodes a string into a
z_owned_bytes_tby copying- Parameters:
bytes – An uninitialized
z_owned_bytes_tto contain the encoded string.str – Pointer to the string to encode.
- Returns:
0if encode successful,negative valueotherwise.
-
_Bool z_timestamp_check(z_timestamp_t ts)
Checks validity of a timestamp
- Parameters:
ts – Timestamp value to check validity of.
- Returns:
trueif timestamp is valid,falseotherwise.
-
z_query_target_t z_query_target_default(void)
Builds a default query target.
- Returns:
The constructed
z_query_target_t.
-
z_query_consolidation_t z_query_consolidation_auto(void)
Builds an automatic query consolidation
z_query_consolidation_t.A query consolidation strategy will automatically be selected depending on the query selector. If selector contains time range properties, no consolidation is performed. Otherwise the
z_query_consolidation_latest()strategy is used.- Returns:
The constructed
z_query_consolidation_t.
-
z_query_consolidation_t z_query_consolidation_default(void)
Builds a default
z_query_consolidation_t.- Returns:
The constructed
z_query_consolidation_t.
-
z_query_consolidation_t z_query_consolidation_latest(void)
Builds a latest query consolidation
z_query_consolidation_t.This strategy optimizes bandwidth on all links in the system but will provide a very poor latency.
- Returns:
The constructed
z_query_consolidation_t.
-
z_query_consolidation_t z_query_consolidation_monotonic(void)
Builds a monotonic query consolidation
z_query_consolidation_t.This strategy offers the best latency. Replies are directly transmitted to the application when received without needing to wait for all replies. This mode does not guarantee that there will be no duplicates.
- Returns:
The constructed
z_query_consolidation_t.
-
z_query_consolidation_t z_query_consolidation_none(void)
Builds a no query consolidation
z_query_consolidation_t.This strategy is useful when querying timeseries data bases or when using quorums.
- Returns:
The constructed
z_query_consolidation_t.
-
void z_query_parameters(const z_loaned_query_t *query, z_view_string_t *parameters)
Gets a query parameters field.
- Parameters:
query – Pointer to the
z_loaned_query_tto get the parameters from.parameters – Pointer to an uninitialized
z_view_string_tto contain the parameters.
-
const z_loaned_bytes_t *z_query_payload(const z_loaned_query_t *query)
Gets a query payload by aliasing it.
- Parameters:
query – Pointer to the
z_loaned_query_tto get the value from.
- Returns:
Pointer to the payload as a
z_loaned_bytes_t.
-
const z_loaned_encoding_t *z_query_encoding(const z_loaned_query_t *query)
Gets a query encoding by aliasing it.
- Parameters:
query – Pointer to the
z_loaned_query_tto get the value from.
- Returns:
Pointer to the encoding as a
z_loaned_encoding_t.
-
const z_loaned_bytes_t *z_query_attachment(const z_loaned_query_t *query)
Gets a query attachment value by aliasing it.
- Parameters:
query – Pointer to the
z_loaned_query_tto get the attachment from.
- Returns:
Pointer to the attachment as a
z_loaned_bytes_t.
-
const z_loaned_keyexpr_t *z_query_keyexpr(const z_loaned_query_t *query)
Gets a query keyexpr by aliasing it.
- Parameters:
query – Pointer to the
z_loaned_query_tto get the keyexpr from.
- Returns:
The keyexpr wrapped as a:c:type:z_keyexpr_t.
-
int8_t z_closure_sample(z_owned_closure_sample_t *closure, z_data_handler_t call, z_dropper_handler_t drop, void *context)
Builds a new sample closure. It consists on a structure that contains all the elements for stateful, memory-leak-free callbacks.
- Parameters:
call – Pointer to the callback function.
contextwill be passed as its last argument.drop – Pointer to the function that will free the callback state.
contextwill be passed as its last argument.context – Pointer to an arbitrary state.
- Returns:
The sample closure.
-
int8_t z_closure_query(z_owned_closure_query_t *closure, z_queryable_handler_t call, z_dropper_handler_t drop, void *context)
Builds a new query closure. It consists on a structure that contains all the elements for stateful, memory-leak-free callbacks.
- Parameters:
call – Pointer to the callback function.
contextwill be passed as its last argument.drop – Pointer to the function that will free the callback state.
contextwill be passed as its last argument.context – Pointer to an arbitrary state.
- Returns:
The query closure.
-
int8_t z_closure_reply(z_owned_closure_reply_t *closure, z_reply_handler_t call, z_dropper_handler_t drop, void *context)
Builds a new reply closure. It consists on a structure that contains all the elements for stateful, memory-leak-free callbacks.
- Parameters:
call – Pointer to the callback function.
contextwill be passed as its last argument.drop – Pointer to the function that will free the callback state.
contextwill be passed as its last argument.context – Pointer to an arbitrary state.
- Returns:
The reply closure.
-
int8_t z_closure_hello(z_owned_closure_hello_t *closure, z_loaned_hello_handler_t call, z_dropper_handler_t drop, void *context)
Builds a new hello closure. It consists on a structure that contains all the elements for stateful, memory-leak-free callbacks.
- Parameters:
call – Pointer to the callback function.
contextwill be passed as its last argument.drop – Pointer to the function that will free the callback state.
contextwill be passed as its last argument.context – Pointer to an arbitrary state.
- Returns:
The hello closure.
-
int8_t z_closure_zid(z_owned_closure_zid_t *closure, z_id_handler_t call, z_dropper_handler_t drop, void *context)
Builds a new zid closure. It consists on a structure that contains all the elements for stateful, memory-leak-free callbacks.
- Parameters:
call – Pointer to the callback function.
contextwill be passed as its last argument.drop – Pointer to the function that will free the callback state.
contextwill be passed as its last argument.context – Pointer to an arbitrary state.
- Returns:
The hello closure.
-
const z_loaned_sample_t *z_sample_loan(const z_owned_sample_t *sample)
Loans a
z_owned_sample_t.- Parameters:
sample – Pointer to a
z_owned_sample_tto loan.
- Returns:
Pointer to the loaned sample as a
z_loaned_sample_t.
-
const char *z_string_data(const z_loaned_string_t *str)
Gets data from a
z_loaned_string_t.- Parameters:
str – Pointer to a
z_loaned_string_tto get data from.
- Returns:
Pointer to the string data.
-
size_t z_string_len(const z_loaned_string_t *str)
Gets string length from a
z_loaned_string_t.- Parameters:
str – Pointer to a
z_loaned_string_tto get length from.
- Returns:
Length of the string.
-
int8_t z_scout(z_owned_scouting_config_t *config, z_owned_closure_hello_t *callback)
Primitives
Scouts for other Zenoh entities like routers and/or peers.
- Parameters:
config – Pointer to a moved
z_owned_scouting_config_tto configure the scouting with.callback – Pointer to a moved
z_owned_closure_hello_tcallback.
- Returns:
0if scouting successfully triggered,negative valueotherwise.
-
int8_t z_open(z_owned_session_t *zs, z_owned_config_t *config)
Opens a Zenoh session.
- Parameters:
zs – Pointer to an uninitialized
z_owned_session_tto store the session info.config – Pointer to a moved
z_owned_config_tto configure the session with.
- Returns:
0if open successful,negative valueotherwise.
-
int8_t z_close(z_owned_session_t *zs)
Closes a Zenoh session.
- Parameters:
zs – Pointer to a moved
z_owned_session_tto close.
- Returns:
0if close successful,negative valueotherwise.
-
int8_t z_info_peers_zid(const z_loaned_session_t *zs, z_owned_closure_zid_t *callback)
Fetches Zenoh IDs of all connected peers.
The callback will be called once for each ID. It is guaranteed to never be called concurrently, and to be dropped before this function exits.
- Parameters:
zs – Pointer to
z_loaned_session_tto fetch peer id from.callback – Pointer to a moved
z_owned_closure_zid_tcallback.
- Returns:
0if operation successfully triggered,negative valueotherwise.
-
int8_t z_info_routers_zid(const z_loaned_session_t *zs, z_owned_closure_zid_t *callback)
Fetches Zenoh IDs of all connected routers.
The callback will be called once for each ID. It is guaranteed to never be called concurrently, and to be dropped before this function exits.
- Parameters:
zs – Pointer to a
z_loaned_session_tto fetch router id from.callback – Pointer to a moved
z_owned_closure_zid_tcallback.
- Returns:
0if operation successfully triggered,negative valueotherwise.
-
z_id_t z_info_zid(const z_loaned_session_t *zs)
Gets the local Zenoh ID associated to a given Zenoh session.
If this function returns an array of 16 zeros, this means the session is invalid.
- Parameters:
zs – Pointer to a
z_loaned_session_tto get the id from.
- Returns:
The local Zenoh ID of the session as
z_id_t.
-
const z_loaned_keyexpr_t *z_sample_keyexpr(const z_loaned_sample_t *sample)
Gets the keyexpr from a sample by aliasing it.
- Parameters:
sample – Pointer to a
z_loaned_sample_tto get the keyexpr from.
- Returns:
The keyexpr wrapped as a
z_loaned_keyexpr_t.
-
const z_loaned_bytes_t *z_sample_payload(const z_loaned_sample_t *sample)
Gets the payload of a sample by aliasing it.
- Parameters:
sample – Pointer to a
z_loaned_sample_tto get the payload from.
- Returns:
The payload wrapped as a
z_loaned_bytes_t.
-
z_timestamp_t z_sample_timestamp(const z_loaned_sample_t *sample)
Gets the timestamp of a sample by aliasing it.
- Parameters:
sample – Pointer to a
z_loaned_sample_tto get the timestamp from.
- Returns:
The timestamp wrapped as a
z_timestamp_t.
-
const z_loaned_encoding_t *z_sample_encoding(const z_loaned_sample_t *sample)
Gets the encoding of a sample by aliasing it.
- Parameters:
sample – Pointer to a
z_loaned_sample_tto get the encoding from.
- Returns:
The encoding wrapped as a
z_loaned_encoding_t*.
-
z_sample_kind_t z_sample_kind(const z_loaned_sample_t *sample)
Gets the kind of a sample by aliasing it.
- Parameters:
sample – Pointer to a
z_loaned_sample_tto get the kind from.
- Returns:
The sample kind wrapped as a
z_sample_kind_t.
-
z_qos_t z_sample_qos(const z_loaned_sample_t *sample)
Gets the qos value of a sample by aliasing it.
- Parameters:
sample – Pointer to a
z_loaned_sample_tto get the qos from.
- Returns:
The qos wrapped as a
z_qos_t.
-
const z_loaned_bytes_t *z_sample_attachment(const z_loaned_sample_t *sample)
Gets the attachment of a value by aliasing it.
- Parameters:
sample – Pointer to a
z_loaned_sample_tto get the attachment from.
- Returns:
Pointer to the attachment as a
z_loaned_bytes_t.
-
void z_put_options_default(z_put_options_t *options)
Builds a
z_put_options_twith default values.:param Pointer to an uninitialized
z_put_options_t.:
-
void z_delete_options_default(z_delete_options_t *options)
Builds a
z_delete_options_twith default values.:param Pointer to an uninitialized
z_delete_options_t.:
-
int8_t z_put(const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr, z_owned_bytes_t *payload, const z_put_options_t *options)
Puts data for a given keyexpr.
- Parameters:
zs – Pointer to a
z_loaned_session_tto put the data through.keyexpr – Pointer to a
z_loaned_keyexpr_tto put the data for.payload – Pointer to a moved
z_owned_bytes_tcontaining the data to put.options – Pointer to a
z_put_options_tto configure the operation.
- Returns:
0if put operation successful,negative valueotherwise.
-
int8_t z_delete(const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr, const z_delete_options_t *options)
Deletes data for a given keyexpr.
- Parameters:
zs – Pointer to a
z_loaned_session_tto delete the data through.keyexpr – Pointer to a
z_loaned_keyexpr_tto delete the data for.options – Pointer to a
z_delete_options_tto configure the operation.
- Returns:
0if delete operation successful,negative valueotherwise.
-
void z_publisher_options_default(z_publisher_options_t *options)
Builds a
z_publisher_options_twith default values.:param Pointer to an uninitialized
z_delete_options_t.:
-
int8_t z_declare_publisher(z_owned_publisher_t *pub, const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr, const z_publisher_options_t *options)
Declares a publisher for a given keyexpr.
Data can be put and deleted with this publisher with the help of the
z_publisher_put()andz_publisher_delete()functions.- Parameters:
zs – Pointer to a
z_loaned_session_tto declare the publisher through.keyexpr – Pointer to a
z_loaned_keyexpr_tto bind the publisher with.options – Pointer to a
z_publisher_options_tto configure the operation.
- Returns:
0if declare successful,negative valueotherwise.
-
int8_t z_undeclare_publisher(z_owned_publisher_t *pub)
Undeclares a publisher.
- Parameters:
pub – Pointer to a moved
z_owned_publisher_tto undeclare.
- Returns:
0if undeclare successful,negative valueotherwise.
-
void z_publisher_put_options_default(z_publisher_put_options_t *options)
Builds a
z_publisher_put_options_twith default values.- Parameters:
options – Pointer to an uninitialized
z_publisher_put_options_t.
-
void z_publisher_delete_options_default(z_publisher_delete_options_t *options)
Builds a
z_publisher_delete_options_twith default values.- Parameters:
options – Pointer to an uninitialized
z_publisher_delete_options_t.
-
int8_t z_publisher_put(const z_loaned_publisher_t *pub, z_owned_bytes_t *payload, const z_publisher_put_options_t *options)
Puts data for the keyexpr bound to the given publisher.
- Parameters:
pub – Pointer to a
z_loaned_publisher_tfrom where to put the data.payload – Pointer to a moved
z_owned_bytes_tcontaining the data to put.options – Pointer to a
z_publisher_put_options_tto configure the operation.
- Returns:
0if put operation successful,negative valueotherwise.
-
int8_t z_publisher_delete(const z_loaned_publisher_t *pub, const z_publisher_delete_options_t *options)
Deletes data from the keyexpr bound to the given publisher.
- Parameters:
pub – Pointer to a
z_loaned_publisher_tfrom where to delete the data.options – Pointer to a
z_publisher_delete_options_tto configure the delete operation.
- Returns:
0if delete operation successful,negative valueotherwise.
-
void z_get_options_default(z_get_options_t *options)
Builds a
z_get_options_twith default values.- Parameters:
options – Pointer to an uninitialized
z_get_options_t.
-
int8_t z_get(const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr, const char *parameters, z_owned_closure_reply_t *callback, z_get_options_t *options)
Sends a distributed query for a given keyexpr.
- Parameters:
zs – Pointer to a
z_loaned_session_tto send the query through.keyexpr – Pointer to a
z_loaned_keyexpr_tto send the query for.parameters – Pointer to the parameters as a null-terminated string.
callback – Pointer to a
z_owned_closure_reply_tcallback.options – Pointer to a
z_get_options_tto configure the operation.
- Returns:
0if put operation successful,negative valueotherwise.
-
_Bool z_reply_is_ok(const z_loaned_reply_t *reply)
Checks if queryable answered with an OK, which allows this value to be treated as a sample.
- Parameters:
reply – Pointer to a
z_loaned_reply_tto check.
- Returns:
trueif queryable answered with an OK,falseotherwise.
-
const z_loaned_sample_t *z_reply_ok(const z_loaned_reply_t *reply)
Gets the content of an OK reply.
You should always make sure that
z_reply_is_ok()returnstruebefore calling this function.- Parameters:
reply – Pointer to a
z_loaned_reply_tto get content from.
- Returns:
The OK reply content wrapped as a
z_loaned_sample_t.
-
const z_loaned_reply_err_t *z_reply_err(const z_loaned_reply_t *reply)
Gets the contents of an error reply.
You should always make sure that
z_reply_is_ok()returnsfalsebefore calling this function.- Parameters:
reply – Pointer to a
z_loaned_reply_tto get content from.
- Returns:
The error reply content wrapped as a
z_loaned_reply_err_t.
-
void z_queryable_options_default(z_queryable_options_t *options)
Builds a
z_queryable_options_twith default values.- Parameters:
options – Pointer to an uninitialized
z_queryable_options_t.
-
int8_t z_declare_queryable(z_owned_queryable_t *queryable, const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr, z_owned_closure_query_t *callback, const z_queryable_options_t *options)
Declares a queryable for a given keyexpr.
- Parameters:
queryable – Pointer to an uninitialized
z_owned_queryable_tto contain the queryable.zs – Pointer to a
z_loaned_session_tto declare the subscriber through.keyexpr – Pointer to a
z_loaned_keyexpr_tto bind the subscriber with.callback – Pointer to a
z_owned_closure_query_tcallback.options – Pointer to a
z_queryable_options_tto configure the declare.
- Returns:
0if declare operation successful,negative valueotherwise.
-
int8_t z_undeclare_queryable(z_owned_queryable_t *queryable)
Undeclares a queryable.
- Parameters:
queryable – Pointer to a
z_owned_queryable_tto undeclare.
- Returns:
0if undeclare operation successful,negative valueotherwise.
-
void z_query_reply_options_default(z_query_reply_options_t *options)
Builds a
z_query_reply_options_twith default values.- Parameters:
options – Pointer to an uninitialized
z_query_reply_options_t.
-
int8_t z_query_reply(const z_loaned_query_t *query, const z_loaned_keyexpr_t *keyexpr, z_owned_bytes_t *payload, const z_query_reply_options_t *options)
Sends a reply to a query.
This function must be called inside of a
z_owned_closure_query_tcallback associated to thez_owned_queryable_t, passing the received query as parameters of the callback function. This function can be called multiple times to send multiple replies to a query. The reply will be considered complete when the callback returns.- Parameters:
query – Pointer to a
z_loaned_query_tto reply.keyexpr – Pointer to a
z_loaned_keyexpr_tto bind the reply with.payload – Pointer to the reply data.
payload_len – The length of the payload.
options – Pointer to a
z_query_reply_options_tto configure the reply.
- Returns:
0if reply operation successful,negative valueotherwise.
-
int8_t z_keyexpr_new(z_owned_keyexpr_t *keyexpr, const char *name)
Builds a new keyexpr.
- Parameters:
keyexpr – Pointer to an uninitialized
z_owned_keyexpr_tto store the keyexpr.name – Pointer to the null-terminated string of the keyexpr.
- Returns:
0if creation successful,negative valueotherwise.
-
int8_t z_declare_keyexpr(z_owned_keyexpr_t *ke, const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr)
Declares a keyexpr, so that it is mapped on a numerical id.
This numerical id is used on the network to save bandwidth and ease the retrieval of the concerned resource in the routing tables.
- Parameters:
ke – Pointer to an uninitialized
z_owned_keyexpr_tto contain the declared keyexpr.zs – Pointer to a
z_loaned_session_tto declare the keyexpr through.keyexpr – Pointer to a
z_loaned_keyexpr_tto bind the keyexpr with.
- Returns:
0if declare successful,negative valueotherwise.
-
int8_t z_undeclare_keyexpr(const z_loaned_session_t *zs, z_owned_keyexpr_t *keyexpr)
Undeclares a keyexpr.
- Parameters:
zs – Pointer to a
z_loaned_session_tto undeclare the data through.keyexpr – Pointer to a moved
z_owned_keyexpr_tto undeclare.
- Returns:
0if undeclare successful,negative valueotherwise.
-
void z_subscriber_options_default(z_subscriber_options_t *options)
Builds a
z_subscriber_options_twith default values.- Parameters:
options – Pointer to an uninitialized
z_subscriber_options_t.
-
int8_t z_declare_subscriber(z_owned_subscriber_t *sub, const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr, z_owned_closure_sample_t *callback, const z_subscriber_options_t *options)
Declares a subscriber for a given keyexpr.
- Parameters:
sub – Pointer to a
z_owned_subscriber_tto contain the subscriber.zs – Pointer to a
z_loaned_session_tto declare the subscriber through.keyexpr – Pointer to a
z_loaned_keyexpr_tto bind the subscriber with.callback – Pointer to a`z_owned_closure_sample_t` callback.
options – Pointer to a
z_subscriber_options_tto configure the operation
- Returns:
0if declare successful,negative valueotherwise.
-
int8_t z_undeclare_subscriber(z_owned_subscriber_t *sub)
Undeclares the subscriber.
- Parameters:
sub – Pointer to a
z_owned_subscriber_tto undeclare.
- Returns:
0if undeclare successful,negative valueotherwise.
-
int8_t z_subscriber_keyexpr(z_owned_keyexpr_t *keyexpr, z_loaned_subscriber_t *sub)
Copies the keyexpr of a subscriber
- Parameters:
keyexpr – Pointer to an uninitialized
z_owned_keyexpr_tto contain the keyexpr.sub – Pointer to a
z_loaned_subscriber_tto copy the keyexpr from.
- Returns:
0if copy successful,negative valueotherwise.
-
void zp_task_read_options_default(zp_task_read_options_t *options)
Multi Thread Tasks helpers
Builds a
zp_task_read_options_twith default value.- Parameters:
options – Pointer to an uninitialized
zp_task_read_options_t.
-
int8_t zp_start_read_task(z_loaned_session_t *zs, const zp_task_read_options_t *options)
Starts a task to read from the network and process the received messages.
Note that the task can be implemented in form of thread, process, etc. and its implementation is platform-dependent.
- Parameters:
zs – Pointer to a
z_loaned_session_tto start the task from.options – Pointer to a
zp_task_read_options_tto configure the task.
- Returns:
0if task started successfully,negative valueotherwise.
-
int8_t zp_stop_read_task(z_loaned_session_t *zs)
Stops the read task.
This may result in stopping a thread or a process depending on the target platform.
- Parameters:
zs – Pointer to a
z_loaned_session_tto stop the task from.
- Returns:
0if task stopped successfully,negative valueotherwise.
-
void zp_task_lease_options_default(zp_task_lease_options_t *options)
Builds a
zp_task_lease_options_twith default value.- Parameters:
options – Pointer to an uninitialized
zp_task_lease_options_t.
-
int8_t zp_start_lease_task(z_loaned_session_t *zs, const zp_task_lease_options_t *options)
Starts a task to handle the session lease.
This task will send
KeepAlivemessages when needed and will close the session when the lease is expired. When operating over a multicast transport, it also periodically sends theJoinmessages. Note that the task can be implemented in form of thread, process, etc. and its implementation is platform-dependent.- Parameters:
zs – Pointer to a
z_loaned_session_tto start the task from.options – Pointer to a
zp_task_lease_options_tto configure the task.
- Returns:
0if task started successfully,negative valueotherwise.
-
int8_t zp_stop_lease_task(z_loaned_session_t *zs)
Stops the lease task.
This may result in stopping a thread or a process depending on the target platform.
- Parameters:
zs – Pointer to a
z_loaned_session_tto stop the task from.
- Returns:
0if task stopped successfully,negative valueotherwise.
-
void zp_read_options_default(zp_read_options_t *options)
Single Thread helpers
Builds a
zp_read_options_twith default value.- Parameters:
options – Pointer to an uninitialized
zp_read_options_t.
-
int8_t zp_read(const z_loaned_session_t *zs, const zp_read_options_t *options)
Executes a single read from the network and process received messages.
- Parameters:
zs – Pointer to a
z_loaned_session_tto execute the read for.options – Pointer to a
zp_read_options_tto configure the operation.
- Returns:
0if execution was successful,negative valueotherwise.
-
void zp_send_keep_alive_options_default(zp_send_keep_alive_options_t *options)
Builds a
zp_send_keep_alive_options_twith default value.- Parameters:
options – Pointer to an uninitialized
zp_send_keep_alive_options_t.
-
int8_t zp_send_keep_alive(const z_loaned_session_t *zs, const zp_send_keep_alive_options_t *options)
Executes a single send keep alive procedure.
- Parameters:
zs – Pointer to a
z_loaned_session_tto execute the send for.options – Pointer to a
zp_send_keep_alive_options_tto configure the operation.
- Returns:
0if execution was successful,negative valueotherwise.
-
void zp_send_join_options_default(zp_send_join_options_t *options)
Builds a
zp_send_join_options_twith default value.- Parameters:
options – Pointer to an uninitialized
zp_send_join_options_t.
-
int8_t zp_send_join(const z_loaned_session_t *zs, const zp_send_join_options_t *options)
Executes a single send join procedure.
- Parameters:
zs – Pointer to a
z_loaned_session_tto execute the send for.options – Pointer to a
zp_send_keep_alive_options_tto configure the operation.
- Returns:
0if execution was successful,negative valueotherwise.