Expand description
§Payload primitives and encoding
The ZBytes type is Zenoh’s representation of raw byte data.
It provides mechanisms for zero-copy creation and access (From<Vec<u8>> and
ZBytes::slices), as well as methods for sequential
reading/writing (ZBytes::reader, ZBytes::writer).
The zenoh-ext crate provides serialization and deserialization of basic types and structures for ZBytes via
z_serialize and
z_deserialize.
The module also provides the Encoding enum to specify the encoding of the payload.
§Examples
§Creating ZBytes
let zbytes = zenoh::bytes::ZBytes::from("Hello, world!");§Converting ZBytes to String
let s = zbytes.try_to_string().unwrap();
assert_eq!(s, "Hello, world!");§Converting ZBytes to Vec<u8>
let vec = zbytes.to_bytes();
assert_eq!(vec.as_ref(), b"Hello, world!");Structs§
- Encoding
- Encoding information
- OptionZ
Bytes - Technical wrapper type for API ergonomicity.
- ZBytes
- ZBytes contains the raw bytes data.
- ZBytes
Reader - A reader that implements
std::io::Readtrait to deserialize from aZBytes. - ZBytes
Slice Iterator - An iterator to iterate on raw bytes slices contained in a
ZBytes. - ZBytes
Writer - A writer that implements
std::io::Writetrait to serialize into aZBytes.