ISpanBufferWriter<T>

Namespace: SnowBank.Buffers · interface

Represents an output sink into which data can be written.

Remarks

This is a simpler version of for containers that don't use managed memory, and thus cannot implement .

Methods

Advance

void Advance(int count)

Notifies ISpanBufferWriter that count amount of data was written to the output Span/Memory

You must request a new buffer after calling Advance to continue writing more data and cannot write to a previously acquired buffer.

GetSpan

Span<T> GetSpan(int sizeHint = 0)

Returns a Span to write to that is at least the requested length (specified by sizeHint). If no sizeHint is provided (or it's equal to 0), some non-empty buffer is returned.

This must never return an empty but it can throw if the requested buffer size is not available.