RefBuffer

RefBuffer is a reference stored buffer for more efficient serialization

Constructors

this
this(size_t threshold, size_t chunkSize)

Constructs a buffer.

Members

Functions

put
void put(ubyte value)
void put(ubyte[] value)

Writes the argument to buffer and stores the reference of writed content if the argument size is smaller than threshold, otherwise stores the reference of argument directly.

Properties

data
ubyte[] data [@property getter]

Returns the buffer contents that excluding references.

vector
iovec[] vector [@property getter]

Forwards to all buffer contents.

Examples

auto packer = packer(RefBuffer(16));  // threshold is 16

// packs data

writev(fd, cast(void*)packer.buffer.vector.ptr, packer.buffer.vector.length);

Meta