Class WriteBuffer

Circular, self-expanding buffer with overflow support. Can be used with functions returning returning the number of the transferred bytes.

class WriteBuffer
  : Buffer ;

The buffer is optimized for situations where you read all the data from it at once (without writing to it occasionally). It can become ineffective if you permanently keep some data in the buffer and alternate writing and reading, because it may allocate and move elements.


this (size)


blockSize immutable(ulong)Size by which the buffer will grow.
buffer_ ubyte[]Internal buffer.
position ulongThe position of the free area in the buffer.
ring ulongBuffer ring area size. After this position begins buffer overflow area.
start ulongBuffer start position.


capacity[get] ulong
free[get] ulong
length[get] ulongNote that length doesn't return the real length of the data, but only the array length that will be returned with buffer next time. Be sure to call buffer and set += until length returns 0.
opDollar[get] ulong
opIndex[get] ubyte[]After calling it, set += to the length could be written.
opOpAssign[set] WriteBufferSets how many bytes were written. It will shrink the buffer appropriately. Always set this property after calling buffer.
opSlice[set] ubyte[]Returns a chunk with data.
opIndex[get] ubyte[]
opSlice[set] ubyte[]


opOpAssign (buffer) Appends data to the buffer.