Function WriteBuffer.opSlice

Returns a chunk with data.

ubyte[] opSlice (
  ulong start,
  ulong end
) pure nothrow @property @nogc @safe;

After calling it, set += to the length could be written.

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

Returns

A chunk of data buffer.

Example

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);