Channels

Classes providing stream interface for Zenoh messages.

enum class zenoh::channels::RecvError

Error of the recv or try_recv operation.

Values:

enumerator Z_DISCONNECTED

Channel is closed and will no more receive any data.

enumerator Z_NODATA

Channel is still active, but no data is currently available in its buffer, future calls to try_recv might still succeed.

class FifoChannel

A FIFO channel.

Public Types

template<class T>
using HandlerType = FifoHandler<T>

Channel handler type.

Public Functions

inline FifoChannel(size_t capacity)

Constructor.

Parameters:

capacity – maximum number of entries in the FIFO buffer of the channel. When the buffer is full, all new attempts to insert data will block, until an entry is fetched and the space is freed in the buffer.

template<class T>
class FifoHandler : public zenoh::Owned<detail::FifoHandlerData<T>::handler_type>

A FIFO channel handler.

Template Parameters:

T – data entry type.

Methods

inline std::variant<T, RecvError> recv() const

Fetch a data entry from the handler’s buffer. If buffer is empty, will block until new data entry arrives.

Returns:

received data entry, if there were any in the buffer, a receive error otherwise.

inline std::variant<T, RecvError> try_recv() const

Fetch a data entry from the handler’s buffer. If buffer is empty, will immediately return.

Returns:

received data entry, if there were any in the buffer, a receive error otherwise.

class RingChannel

A circular buffer channel.

Public Types

template<class T>
using HandlerType = RingHandler<T>

Channel handler type.

Public Functions

inline RingChannel(size_t capacity)

Constructor.

Parameters:

capacity – maximum number of entries in circular buffer of the channel. When the buffer is full, the older entries will be removed to provide room for the new ones.

template<class T>
class RingHandler : public zenoh::Owned<detail::RingHandlerData<T>::handler_type>

A circular buffer channel handler.

Template Parameters:

T – data entry type.

Methods

inline std::variant<T, RecvError> recv() const

Fetch a data entry from the handler’s buffer. If buffer is empty, will block until new data entry arrives.

Returns:

received data, entry if there were any in the buffer, a receive error otherwise.

inline std::variant<T, RecvError> try_recv() const

Fetch a data entry from the handler’s buffer. If buffer is empty, will immediately return.

Returns:

received data entry, if there were any in the buffer, a receive error otherwise.