Zenoh API Reference

Zenoh /zeno/ is a stack that unifies data in motion, data at rest and computations. It elegantly blends traditional pub/sub with geo distributed storage, queries and computations, while retaining a level of time and space efficiency that is well beyond any of the mainstream stacks.

Before delving into the examples, we need to introduce few Zenoh concepts. First off, in Zenoh you will deal with Resources, where a resource is made up of a key and a value. The other concept you’ll have to familiarize yourself with are key expressions, such as robot/sensor/temp, robot/sensor/*, robot/**, etc. As you can gather, the above key expression denotes set of keys, while the * and ** are wildcards representing respectively (1) a single chunk (non-empty sequence of characters that doesn’t contain /), and (2) any amount of chunks (including 0).

Below are some examples that highlight these key concepts and show how easy it is to get started with.

Quick start examples:

Publish a key/value pair onto Zenoh

>>> import zenoh
>>> with zenoh.open() as session:
>>>     session.put('demo/example/hello', 'Hello World!')

Subscribe to a set of keys with Zenoh

>>> import zenoh, time
>>> def listener(sample):
>>>     print(f"{sample.key_expr} => {sample.payload.to_string()}")
>>>
>>> with zenoh.open() as session:
>>>     with session.declare_subscriber('demo/example/**', listener) as subscriber:
>>>         time.sleep(60)

Get keys/values from zenoh

>>> import zenoh
>>> with zenoh.open() as session:
>>>     for response in session.get('demo/example/**'):
>>>         response = response.ok
>>>         print(f"{response.key_expr} => {response.payload.to_string()}")

module zenoh

final exception zenoh.ZError
final class zenoh.Config

The main configuration structure for Zenoh.

Return type:

Self

classmethod from_env()
Return type:

Self

classmethod from_file(path)
Parameters:

path (str | Path) –

Return type:

Self

classmethod from_json5(json)
Parameters:

json (str) –

Return type:

Self

get_json(key)
Parameters:

key (str) –

Return type:

Any

insert_json5(key, value)
Parameters:
  • key (str) –

  • value (Any) –

final enum zenoh.CongestionControl(value)

The kind of congestion control.

Valid values are as follows:

DROP = <CongestionControl.DROP: 1>
BLOCK = <CongestionControl.BLOCK: 2>
final enum zenoh.ConsolidationMode(value)

The kind of consolidation.

Valid values are as follows:

AUTO = <ConsolidationMode.AUTO: 1>
NONE = <ConsolidationMode.NONE: 2>
MONOTONIC = <ConsolidationMode.MONOTONIC: 3>
LATEST = <ConsolidationMode.LATEST: 4>
final class zenoh.Encoding(encoding=None)

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 parcticular useful in helping Zenoh to perform additional network optimizations.

Parameters:

encoding (str | None) –

Return type:

Self

with_schema(schema)

Set a schema to this encoding. Zenoh does not define what a schema is and its semantics are left to the implementer. E.g. a common schema for text/plain encoding is utf-8.

Parameters:

schema (str) –

Return type:

Self

APPLICATION_CBOR: Self

A Concise Binary Object Representation (CBOR)-encoded data.

Constant alias for string: “application/cbor”.

APPLICATION_CDR: Self

A Common Data Representation (CDR)-encoded data.

Constant alias for string: “application/cdr

APPLICATION_COAP_PAYLOAD: Self

Constrained Application Protocol (CoAP) data intended for CoAP-to-HTTP and HTTP-to-CoAP proxies.

Constant alias for string: “application/coap-payload”.

APPLICATION_JAVA_SERIALIZED_OBJECT: Self

A Java serialized object.

Constant alias for string: “application/java-serialized-object”.

APPLICATION_JSON: Self

JSON data intended to be consumed by an application.

Constant alias for string: “application/json”.

APPLICATION_JSONPATH: Self

A JSONPath defines a string syntax for selecting and extracting JSON values from within a given JSON value.

Constant alias for string: “application/jsonpath”.

APPLICATION_JSON_PATCH_JSON: Self

Defines a JSON document structure for expressing a sequence of operations to apply to a JSON document.

Constant alias for string: “application/json-patch+json”.

APPLICATION_JSON_SEQ: Self

A JSON text sequence consists of any number of JSON texts, all encoded in UTF-8.

Constant alias for string: “application/json-seq”.

APPLICATION_JWT: Self

A JSON Web Token (JWT).

Constant alias for string: “application/jwt”.

APPLICATION_MP4: Self

An application-specific MPEG-4 encoded data, either audio or video.

Constant alias for string: “application/mp4”.

APPLICATION_OCTET_STREAM: Self

An application-specific stream of bytes.

Constant alias for string: “application/octet-stream”.

APPLICATION_OPENMETRICS_TEXT: Self

An openmetrics text data representation, commonly used by Prometheus.

Constant alias for string: “application/openmetrics-text”.

APPLICATION_PROTOBUF: Self

An application-specific protobuf-encoded data.

Constant alias for string: “application/protobuf”.

APPLICATION_PYTHON_SERIALIZED_OBJECT: Self

A Python object serialized using pickle.

Constant alias for string: “application/python-serialized-object”.

APPLICATION_SOAP_XML: Self

A SOAP 1.2 message serialized as XML 1.0.

Constant alias for string: “application/soap+xml”.

APPLICATION_SQL: Self

An application-specific SQL query.

Constant alias for string: “application/sql”.

APPLICATION_XML: Self

An XML file intended to be consumed by an application.

Constant alias for string: “application/xml”.

APPLICATION_X_WWW_FORM_URLENCODED: Self

An encoded a list of tuples, each consisting of a name and a value.

Constant alias for string: “application/x-www-form-urlencoded”.

APPLICATION_YAML: Self

YAML data intended to be consumed by an application.

Constant alias for string: “application/yaml”.

APPLICATION_YANG: Self

A YANG-encoded data commonly used by the Network Configuration Protocol (NETCONF).

Constant alias for string: “application/yang”.

AUDIO_AAC: Self

A MPEG-4 Advanced Audio Coding (AAC) media.

Constant alias for string: “audio/aac”.

AUDIO_FLAC: Self

A Free Lossless Audio Codec (FLAC) media.

Constant alias for string: “audio/flac”.

AUDIO_MP4: Self

An audio codec defined in MPEG-1, MPEG-2, MPEG-4, or registered at the MP4 registration authority.

Constant alias for string: “audio/mp4”.

AUDIO_OGG: Self

An Ogg-encapsulated audio stream.

Constant alias for string: “audio/ogg”.

AUDIO_VORBIS: Self

A Vorbis-encoded audio stream.

Constant alias for string: “audio/vorbis”.

IMAGE_BMP: Self

A BitMap (BMP) image.

Constant alias for string: “image/bmp”.

IMAGE_GIF: Self

A Graphics Interchange Format (GIF) image.

Constant alias for string: “image/gif”.

IMAGE_JPEG: Self

A Joint Photographic Experts Group (JPEG) image.

Constant alias for string: “image/jpeg”.

IMAGE_PNG: Self

A Portable Network Graphics (PNG) image.

Constant alias for string: “image/png”.

IMAGE_WEBP: Self

A Web Protable (WebP) image.

Constant alias for string: “image/webp

TEXT_CSS: Self

A CSS file.

Constant alias for string: “text/css”.

TEXT_CSV: Self

A CSV file.

Constant alias for string: “text/csv”.

TEXT_HTML: Self

An HTML file.

Constant alias for string: “text/html”.

TEXT_JAVASCRIPT: Self

A JavaScript file.

Constant alias for string: “text/javascript”.

TEXT_JSON: Self

JSON data intended to be human readable.

Constant alias for string: “text/json”.

TEXT_JSON5: Self

JSON5 encoded data intended to be human readable.

Constant alias for string: “text/json5”.

TEXT_MARKDOWN: Self

A MarkDown file.

Constant alias for string: “text/markdown”.

TEXT_PLAIN: Self

A textual file.

Constant alias for string: “text/plain”.

TEXT_XML: Self

An XML file that is human readable.

Constant alias for string: “text/xml”.

TEXT_YAML: Self

YAML data intended to be human readable.

Constant alias for string: “text/yaml”.

VIDEO_H261: Self

An h261-encoded video stream.

Constant alias for string: “video/h261”.

VIDEO_H263: Self

An h263-encoded video stream.

Constant alias for string: “video/h263”.

VIDEO_H264: Self

An h264-encoded video stream.

Constant alias for string: “video/h264”.

VIDEO_H265: Self

An h265-encoded video stream.

Constant alias for string: “video/h265”.

VIDEO_H266: Self

An h266-encoded video stream.

Constant alias for string: “video/h266”.

VIDEO_MP4: Self

A video codec defined in MPEG-1, MPEG-2, MPEG-4, or registered at the MP4 registration authority.

Constant alias for string: “video/mp4”.

VIDEO_OGG: Self

An Ogg-encapsulated video stream.

Constant alias for string: “video/ogg”.

VIDEO_RAW: Self

An uncompressed, studio-quality video stream.

Constant alias for string: “video/raw”.

VIDEO_VP8: Self

A VP8-encoded video stream.

Constant alias for string: “video/vp8”.

VIDEO_VP9: Self

A VP9-encoded video stream.

Constant alias for string: “video/vp9”.

ZENOH_BYTES: Self

Just some bytes.

Constant alias for string: “zenoh/bytes”.

ZENOH_SERIALIZED: Self

Zenoh serialized data.

Constant alias for string: “zenoh/serialized”.

ZENOH_STRING: Self

A UTF-8 string.

Constant alias for string: “zenoh/string”.

final class zenoh.Hello
property locators: list[str]
property whatami: WhatAmI
property zid: ZenohId
final class zenoh.KeyExpr(key_expr)

A possibly-owned version of keyexpr that may carry optimisations for use with a Session that may have declared it. Check keyexpr’s documentation for detailed explainations of the Key Expression Language

Parameters:

key_expr (str) –

Return type:

Self

classmethod autocanonize(key_expr)

Canonizes the passed value before returning it as a KeyExpr. Will return Err if the passed value isn’t a valid key expression despite canonization.

Parameters:

key_expr (str) –

Return type:

Self

concat(other)

Performs string concatenation and returns the result as a KeyExpr if possible. You should probably prefer KeyExpr::join as Zenoh may then take advantage of the hierachical separation it inserts.

Parameters:

other (str) –

Return type:

KeyExpr

includes(other)

Returns true if self includes other, i.e. the set defined by self contains every key belonging to the set defined by other.

Parameters:

other (KeyExpr | str) –

Return type:

bool

intersects(other)

Returns true if the keyexprs intersect, i.e. there exists at least one key which is contained in both of the sets defined by self and other.

Parameters:

other (KeyExpr | str) –

Return type:

bool

join(other)

Joins both sides, inserting a / in between them. This should be your prefered method when concatenating path segments.

Parameters:

other (str) –

Return type:

KeyExpr

relation_to(other)
Returns the relation between self and other from self’s point of view (SetIntersectionLevel::Includes signifies that self includes other).

Note that this is slower than keyexpr::intersects and keyexpr::includes, so you should favor these methods for most applications.

Warning

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.

Parameters:

other (KeyExpr | str) –

Return type:

SetIntersectionLevel

final class zenoh.Liveliness
declare_subscriber(key_expr, handler=None, *, history=None)

Create a Subscriber for liveliness changes matching the given key expression.

Parameters:
Return type:

Subscriber

declare_token(key_expr)

Create a LivelinessToken for the given key expression.

Parameters:

key_expr (KeyExpr | str) –

Return type:

LivelinessToken

get(key_expr, handler=None, *, timeout=None)

Query liveliness tokens with matching key expressions.

Parameters:
Return type:

Handler

final class zenoh.LivelinessToken
undeclare()

Undeclare the LivelinessToken.

final class zenoh.Parameters(parameters=None)
Parameters:

parameters (dict[str, str] | str | None) –

extend(parameters)

Extend these properties with other properties.

Parameters:

parameters (Parameters | dict[str, str] | str) –

get(key, default=None)

Returns the value corresponding to the key.

Parameters:
  • key (str) –

  • default (str | None) –

Return type:

str | None

insert(key, value)

Inserts a key-value pair into the map. If the map did not have this key present, None` is returned. If the map did have this key present, the value is updated, and the old value is returned.

Parameters:
  • key (str) –

  • value (str) –

is_empty()

Returns true if properties does not contain anything.

Return type:

bool

is_ordered()

Returns true if all keys are sorted in alphabetical order.

Return type:

bool

remove(key)

Removes a key from the map, returning the value at the key if the key was previously in the properties.

Parameters:

key (str) –

values(key)

Returns the list of values corresponding to the key.

Parameters:

key (str) –

Return type:

list[str]

final enum zenoh.Priority(value)

The Priority of zenoh messages.

Valid values are as follows:

REAL_TIME = <Priority.REAL_TIME: 1>
INTERACTIVE_HIGH = <Priority.INTERACTIVE_HIGH: 2>
INTERACTIVE_LOW = <Priority.INTERACTIVE_LOW: 3>
DATA_HIGH = <Priority.DATA_HIGH: 4>
DATA = <Priority.DATA: 5>
DATA_LOW = <Priority.DATA_LOW: 6>
BACKGROUND = <Priority.BACKGROUND: 7>
final class zenoh.Publisher

A publisher that allows to send data through a stream. Publishers are automatically undeclared when dropped.

delete(*, attachment=None)

Delete data.

Parameters:

attachment (Any | None) –

put(payload, *, encoding=None, attachment=None)

Put data.

Parameters:
  • payload (Any) –

  • encoding (Encoding | str | None) –

  • attachment (Any | None) –

undeclare()

Undeclares the Publisher, informing the network that it needn’t optimize publications for its key expression anymore.

property congestion_control: CongestionControl
property encoding: Encoding
property key_expr: KeyExpr
property priority: Priority
property reliability: Reliability

Warning

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.

final class zenoh.Querier
A querier that allows to send queries to a queryable.

Queriers are automatically undeclared when dropped.

Warning

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.

get(handler=None, *, parameters=None, payload=None, encoding=None, attachment=None)

Sends a query.

Parameters:
Return type:

Handler

undeclare()

Undeclares the Querier, informing the network that it needn’t optimize queries for its key expression anymore.

property key_expr: KeyExpr
final class zenoh.Query

Structs received by a Queryable.

drop()

Drop the instance of a query. The query will only be finalized when all query instances (one per queryable matched) are dropped. Finalization is required to not have query hanging on the querier side.

This method should be called after handling the query, as Python finalizers are not reliable, especially when it comes to loop variables. It is also possible, and advised, to use query context manager, which calls drop on exit. Once a query is dropped, it’s no more possible to use it, and its methods will raise an exception.

reply(key_expr, payload, *, encoding=None, congestion_control=None, priority=None, express=None, attachment=None)

Sends a reply to this Query. By default, queries only accept replies whose key expression intersects with the query’s. Unless the query has enabled disjoint replies (you can check this through Query::accepts_replies), replying on a disjoint key expression will result in an error when resolving the reply.

Parameters:
  • key_expr (KeyExpr | str) –

  • payload (Any) –

  • encoding (Encoding | str | None) –

  • congestion_control (CongestionControl | None) –

  • priority (Priority | None) –

  • express (bool | None) –

  • attachment (Any | None) –

reply_del(key_expr, *, congestion_control=None, priority=None, express=None, attachment=None)

Sends a delete reply to this Query. By default, queries only accept replies whose key expression intersects with the query’s. Unless the query has enabled disjoint replies (you can check this through Query::accepts_replies), replying on a disjoint key expression will result in an error when resolving the reply.

Parameters:
  • key_expr (KeyExpr | str) –

  • congestion_control (CongestionControl | None) –

  • priority (Priority | None) –

  • express (bool | None) –

  • attachment (Any | None) –

reply_err(payload, *, encoding=None)

Sends an error reply to this Query.

Parameters:
  • payload (Any) –

  • encoding (Encoding | str | None) –

property attachment: ZBytes | None
property encoding: Encoding | None
property key_expr: KeyExpr
property parameters: Parameters
property payload: ZBytes | None
property selector: Selector
final class zenoh.QueryConsolidation(mode, /)
Parameters:

mode (ConsolidationMode) –

Return type:

Self

AUTO: Self
DEFAULT: Self
property mode: ConsolidationMode
final enum zenoh.QueryTarget(value)

The kind of consolidation used.

Valid values are as follows:

BEST_MATCHING = <QueryTarget.BEST_MATCHING: 1>
ALL = <QueryTarget.ALL: 2>
ALL_COMPLETE = <QueryTarget.ALL_COMPLETE: 3>
final class zenoh.Queryable

A queryable that provides data through a Handler. Queryables can be created from a zenoh Session with the declare_queryable function and the with function of the resulting builder. Queryables are automatically undeclared when dropped.

recv()
Parameters:

self (Queryable[Handler[Query]]) –

Return type:

Query

try_recv()
Parameters:

self (Queryable[Handler[Query]]) –

Return type:

Query | None

undeclare()
property handler: _H
property key_expr: KeyExpr
final enum zenoh.Reliability(value)

Warning

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.

Valid values are as follows:

BEST_EFFORT = <Reliability.BEST_EFFORT: 1>
RELIABLE = <Reliability.RELIABLE: 2>
final class zenoh.Reply

Structs returned by a get.

property err: ReplyError | None
property ok: Sample | None
property replier_id: ZenohId | None

Warning

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.

property result: Sample | ReplyError
final class zenoh.ReplyError
property encoding: Encoding
property payload: ZBytes
final class zenoh.Sample
property attachment: ZBytes | None
property congestion_control: CongestionControl

Gets the congestion control of this Sample.

property encoding: Encoding

Gets the encoding of this sample.

property express: bool

Gets the express flag value.

If true, the message is not batched during transmission, in order to reduce latency.

property key_expr: KeyExpr

Gets the key expression on which this Sample was published.

property kind: SampleKind

Gets the kind of this Sample.

property payload: ZBytes

Gets the payload of this Sample.

property priority: Priority

Gets the priority of this Sample.

property timestamp: Timestamp

Gets the timestamp of this Sample.

final enum zenoh.SampleKind(value)

Valid values are as follows:

PUT = <SampleKind.PUT: 1>
DELETE = <SampleKind.DELETE: 2>
final class zenoh.Scout
recv()
Parameters:

self (Scout[Handler[Hello]]) –

Return type:

Hello

stop()
try_recv()
Parameters:

self (Scout[Handler[Hello]]) –

Return type:

Hello | None

property handler: _H
final class zenoh.Selector(arg, /, parameters=None)

A selector is the combination of a Key Expression, which defines the set of keys that are relevant to an operation, and a set of parameters with a few intendend uses: specifying arguments to a queryable, allowing the passing of Remote Procedure Call parameters filtering by value, filtering by metadata, such as the timestamp of a value, specifying arguments to zenoh when using the REST API. When in string form, selectors look a lot like a URI, with similar semantics: the key_expr before the first ? must be a valid key expression. the parameters after the first ? should be encoded like the query section of a URL: parameters are separated by &, the parameter name and value are separated by the first =, in the absence of =, the parameter value is considered to be the empty string, both name and value should use percent-encoding (URL-encoding) to escape characters, defining a value for the same parameter name twice is considered undefined behavior, with the encouraged behaviour being to reject operations when a duplicate parameter is detected. Zenoh intends to standardize the usage of a set of parameter names. To avoid conflicting with RPC parameters, the Zenoh team has settled on reserving the set of parameter names that start with non-alphanumeric characters. The full specification for selectors is available here , it includes standardized parameters. Queryable implementers are encouraged to prefer these standardized parameter names when implementing their associated features, and to prefix their own parameter names to avoid having conflicting parameter names with other queryables. Here are the currently standardized parameters for Zenoh (check the specification page for the exhaustive list): _time: used to express interest in only values dated within a certain time range, values for this parameter must be readable by the Zenoh Time DSL for the value to be considered valid. [unstable] _anyke: used in queries to express interest in replies coming from any key expression. By default, only replies whose key expression match query’s key expression are accepted. _anyke disables the query-reply key expression matching check.

Parameters:
  • arg (_IntoKeyExpr | str) –

  • parameters (_IntoParameters | None) –

property key_expr: KeyExpr
property parameters: Parameters
final class zenoh.Session

A zenoh session.

close()

Close the zenoh Session. Sessions are automatically closed when dropped, but you may want to use this function to handle errors or close the Session asynchronously.

declare_keyexpr(key_expr)

Informs Zenoh that you intend to use the provided key_expr multiple times and that it should optimize its transmission. The returned KeyExpr’s internal structure may differ from what you would have obtained through a simple key_expr.try_into(), to save time on detecting the optimizations that have been associated with it.

Parameters:

key_expr (KeyExpr | str) –

declare_publisher(key_expr, *, encoding=None, congestion_control=None, priority=None, express=None, reliability=None)

Create a Publisher for the given key expression.

Parameters:
Return type:

Publisher

declare_querier(key_expr, *, target=None, consolidation=None, timeout=None, congestion_control=None, priority=None, express=None)

Create a Querier for the given key expression. .. warning:: This API has been marked as unstable: it works as advertised, but it may be changed in a future release.

Parameters:
Return type:

Querier

declare_queryable(key_expr, handler=None, *, complete=None)

Create a Queryable for the given key expression.

Parameters:
Return type:

Queryable

declare_subscriber(key_expr, handler=None)

Create a Subscriber for the given key expression.

Parameters:
Return type:

Subscriber

delete(key_expr, *, congestion_control=None, priority=None, express=None, attachment=None)

Delete data for a given key expression.

Parameters:
  • key_expr (KeyExpr | str) –

  • congestion_control (CongestionControl | None) –

  • priority (Priority | None) –

  • express (bool | None) –

  • attachment (Any | None) –

get(selector, handler=None, *, target=None, consolidation=None, timeout=None, congestion_control=None, priority=None, express=None, payload=None, encoding=None, attachment=None)

Query data from the matching queryables in the system. Unless explicitly requested via GetBuilder::accept_replies, replies are guaranteed to have key expressions that match the requested selector.

Parameters:
Return type:

Handler

is_closed()

Check if the session has been closed.

Return type:

bool

liveliness()

Obtain a Liveliness instance tied to this Zenoh session.

Return type:

Liveliness

new_timestamp()

Get a new Timestamp from a Zenoh session.

The returned timestamp has the current time, with the session’s runtime ZenohId.

Return type:

Timestamp

put(key_expr, payload, *, encoding=None, congestion_control=None, priority=None, express=None, attachment=None)

Put data on zenoh for a given key expression.

Parameters:
  • key_expr (KeyExpr | str) –

  • payload (Any) –

  • encoding (Encoding | str | None) –

  • congestion_control (CongestionControl | None) –

  • priority (Priority | None) –

  • express (bool | None) –

  • attachment (Any | None) –

undeclare(obj)
Parameters:

obj (KeyExpr) –

zid()

Returns the identifier of the current session. zid() is a convenient shortcut.

Return type:

ZenohId

property info: SessionInfo
final class zenoh.SessionInfo
peers_zid()

Return the ZenohId of the zenoh peers this process is currently connected to.

Return type:

list[ZenohId]

routers_zid()

Return the ZenohId of the zenoh routers this process is currently connected to or the ZenohId of the current router if this code is run from a router (plugin).

Return type:

list[ZenohId]

zid()

Return the ZenohId of the current zenoh Session.

Return type:

ZenohId

final enum zenoh.SetIntersectionLevel(value)

Warning

This API has been marked as unstable: it works as advertised, but it may be changed in a future release.

Valid values are as follows:

DISJOINT = <SetIntersectionLevel.DISJOINT: 1>
INTERSECTS = <SetIntersectionLevel.INTERSECTS: 2>
INCLUDES = <SetIntersectionLevel.INCLUDES: 3>
EQUALS = <SetIntersectionLevel.EQUALS: 4>
final class zenoh.Subscriber

A subscriber that provides data through a Handler. Subscribers can be created from a zenoh Session with the declare_subscriber function and the with function of the resulting builder. Subscribers are automatically undeclared when dropped.

recv()
Parameters:

self (Subscriber[Handler[Sample]]) –

Return type:

Sample

try_recv()
Parameters:

self (Subscriber[Handler[Sample]]) –

Return type:

Sample | None

undeclare()

Close a Subscriber. Subscribers are automatically closed when dropped, but you may want to use this function to handle errors or close the Subscriber asynchronously.

property handler: _H
property key_expr: KeyExpr
final class zenoh.Timestamp
get_time()
Return type:

datetime

final enum zenoh.WhatAmI(value)

Valid values are as follows:

ROUTER = <WhatAmI.ROUTER: 1>
PEER = <WhatAmI.PEER: 2>
CLIENT = <WhatAmI.CLIENT: 3>
final class zenoh.WhatAmIMatcher
client()
Return type:

Self

classmethod empty()
Return type:

Self

is_empty()
Return type:

bool

matches(whatami)
Parameters:

whatami (WhatAmI) –

Return type:

bool

peer()
Return type:

Self

router()
Return type:

Self

final class zenoh.ZBytes(bytes=None)

ZBytes contains the serialized bytes of user data.

It provides convenient methods to the user for serialization/deserialization.

NOTE Zenoh semantic and protocol take care of sending and receiving bytes without restricting the actual data types. Default (de)serializers are provided for convenience to the users to deal with primitives data types via a simple out-of-the-box encoding. They are NOT by any means the only (de)serializers users can use nor a limitation to the types supported by Zenoh. Users are free and encouraged to use any data format of their choice like JSON, protobuf, flatbuffers, etc.

Parameters:

bytes (bytearray | bytes | str) –

Return type:

Self

to_bytes()
Return type:

bytes

to_string()
Return type:

str

final class zenoh.ZenohId

The global unique id of a zenoh peer.

zenoh.init_log_from_env_or(level)

Redirect zenoh logs to stdout, according to the RUST_LOG environment variable.

For example, RUST_LOG=debug will set the log level to DEBUG. If RUST_LOG is not set, then logging is set to the provided level.

Parameters:

level (str) –

zenoh.open(config)

Open a zenoh Session.

Parameters:

config (Config) –

Return type:

Session

zenoh.scout(handler=None, what=None, config=None)

Scout for routers and/or peers.

scout spawns a task that periodically sends scout messages and waits for Hello replies. Drop the returned Scout to stop the scouting task.

Parameters:
Return type:

Scout

zenoh.try_init_log_from_env()

Redirect zenoh logs to stdout, according to the RUST_LOG environment variable.

For example, RUST_LOG=debug will set the log level to DEBUG. If RUST_LOG is not set, then logging is not enabled.

module zenoh.handlers

final class zenoh.handlers.Callback(callback, drop=None, *, indirect=True)
Parameters:
  • callback (Callable[[_T], Any]) –

  • drop (Callable[[], Any] | None) –

  • indirect (bool) –

Return type:

Self

property callback: Callable[[_T], Any]
property drop: Callable[[], Any] | None
property indirect: bool
final class zenoh.handlers.DefaultHandler

The default handler in Zenoh is a FIFO queue.

final class zenoh.handlers.FifoChannel(capacity)

The default handler in Zenoh is a FIFO queue.

Parameters:

capacity (int) –

Return type:

Self

final class zenoh.handlers.Handler

Handler for DefaultHandler/FifoHandler/RingHandler.

recv()
Return type:

_T

try_recv()
Return type:

_T | None

final class zenoh.handlers.RingChannel(capacity)

A synchrounous ring channel with a limited size that allows users to keep the last N data.

Parameters:

capacity (int) –

Return type:

Self