|
VLink
2.0.0
A high-performance communication middleware
|
Canonical 128-byte binary payload carrier with inline storage, multi-mode ownership and LZAV compression. 更多...
#include <cstddef>#include <cstdint>#include <cstring>#include <iostream>#include <string>#include <string_view>#include <vector>#include "./macros.h"类 | |
| class | vlink::Bytes |
| Fixed-size 128-byte buffer holder with SBO, five ownership modes and integrated codecs. 更多... | |
命名空间 | |
| vlink | |
Canonical 128-byte binary payload carrier with inline storage, multi-mode ownership and LZAV compression.
Every binary buffer that crosses a VLink boundary (publish, subscribe, RPC argument, field value, proxy snapshot) flows through a vlink::Bytes object. The class fuses five orthogonal concerns into a single fixed-size 128-byte structure: small-buffer optimisation, ownership tagging, loaned-memory tracking, prefix-offset reservation and a compression / encoding utility surface.
| Factory | Owns memory | Frees on destroy | Aliases source pointer | Typical caller |
|---|---|---|---|---|
Bytes::create | yes | yes | no | Fresh allocation |
Bytes::shallow_copy | no | no | yes | Zero-copy view |
Bytes::deep_copy | when sized | when sized | no | Detached owned copy |
Bytes::loan_internal | no (loaned) | no | yes | Iceoryx zero-copy |
Bytes::shallow_copy_ptr | no | no | yes | Opaque pointer wrap |
* +------------------------------------------------------------------+ * | Bytes (128 B) | * +-------------------------+-------+----+------+-------+------------+ * | stack_data_ (96 B SBO) | owner | ln | off | size | capacity | * +-------------------------+-------+----+------+-------+------------+ * | * | (when size > 96 B) * v * +--------------------------------+ * | heap buffer from MemoryPool | * | [ offset prefix ][ payload ] | * +--------------------------------+ *
* byte: 0 1 2 3 4 5 6 7 8 N-4 N-3 N-2 N-1 * +---+---+---+---+---+---+---+---+---+ - - - - - - - - - +----+----+----+----+ * field: | header magic | original size BE | LZAV payload | footer magic | * +---+---+---+---+---+---+---+---+---+ - - - - - - - - - +----+----+----+----+ * 17 49 B2 6F A7 05 ED 71 *
Buffers below or equal to kStackSize (96 bytes) reside entirely in stack_data_; only larger payloads pull from MemoryPool::global_instance() through bytes_malloc. The total object footprint is fixed at 128 bytes regardless of payload size. An offset prefix reserves space at the head of the buffer so transport adapters can prepend protocol headers without realloc; data() returns real_data() + offset().