Class ZBytes
-
- All Implemented Interfaces:
-
io.zenoh.bytes.IntoZBytes
public final class ZBytes implements IntoZBytes
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.
A ZBytes created from user data (from) is a plain value — it never holds native memory. A received ZBytes (a sample's payload or attachment, a query payload, a reply) wraps a native buffer that is freed automatically on the first bytes access (the bytes are copied out lazily, once). A received ZBytes whose content is never read keeps its native buffer allocated: unlike every other handle-owning class in this SDK, ZBytes is deliberately NOT covered by the garbage-collection backstop — payloads are the per-message hot path, and registering a GC cleaner per message measured −23% throughput at small payload sizes. In callback-based subscribers/queryables, access (or discard) payloads and attachments you care about; unread ones on dropped samples are the one place native memory can be retained.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classZBytes.Companion
-
Field Summary
Fields Modifier and Type Field Description public final static ZBytes.CompanionCompanion
-
Method Summary
Modifier and Type Method Description final ByteArraytoBytes()Returns the internal byte representation of the ZBytes. final StringtryToString()Attempts to decode the ZBytes into a string with UTF-8 encoding. StringtoString()ZBytesinto()Booleanequals(Object other)<Error class: unknown class>hashCode()-
-
Method Detail
-
tryToString
final String tryToString()
Attempts to decode the ZBytes into a string with UTF-8 encoding.
-
hashCode
<Error class: unknown class> hashCode()
-
-
-
-