WriteBuffer.opSlice

Returns a chunk with data.

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

$(D_PSYMBOL opIndex) 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.

struct WriteBuffer(T = ubyte)
T[]
opSlice
(
size_t start
,
size_t end
)

Return Value

Type: T[]

A chunk of data buffer.

Examples

auto b = WriteBuffer!ubyte(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;

Meta