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 class ZBytes.Companion
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description