WriteBuffer.opSlice

Returns a chunk with data.

After calling it, set $(D_KEYWORD +=) to the length could be written.

$(D_PSYMBOL buffer) may return only part of the data. You may need to call it (and set $(D_KEYWORD +=) several times until $(D_PSYMBOL length) is 0). If all the data can be written, maximally 3 calls are required.

class WriteBuffer
@property pure nothrow @safe @nogc
ubyte[]
opSlice
(
size_t start
,
size_t end
)

Return Value

Type: ubyte[]

A chunk of data buffer.

Examples

auto b = defaultAllocator.make!WriteBuffer(6);
ubyte[6] buf = [23, 23, 255, 128, 127, 9];

b ~= buf;
assert(b[0..$] == buf[0..6]);
b += 2;

assert(b[0..$] == buf[2..6]);

b ~= buf;
assert(b[0..$] == buf[2..6]);
b += b.length;

assert(b[0..$] == buf[0..6]);
b += b.length;

defaultAllocator.dispose(b);

Meta