DotNext by Roman Sakno

<PackageReference Include="DotNext" Version="2.9.5" />

 MemoryWriter<T>

Represents memory-backed output sink which T data can be written.
public abstract int Capacity { get; }

Gets the total amount of space within the underlying memory.

public int FreeCapacity { get; }

Gets the amount of space available that can still be written into without forcing the underlying buffer to grow.

public T& modreq(System.Runtime.InteropServices.InAttribute) this[int index] { get; }

Gets the element at the specified index.

public int WrittenCount { get; }

Gets the amount of data written to the underlying memory so far.

public abstract ReadOnlyMemory<T> WrittenMemory { get; }

Gets the data written to the underlying buffer so far.

public void Add(T item)

Writes single element.

public void AddAll(ICollection<T> items)

Writes multiple elements.

public void Advance(int count)

Notifies this writer that count of data items were written.

public virtual void Clear()

Clears the data written to the underlying memory.

public abstract void Clear(bool reuseBuffer)

Clears the data written to the underlying memory.

Gets enumerator over all written elements.

public abstract Memory<T> GetMemory(int sizeHint = 0)

Returns the memory to write to that is at least the requested size.

public virtual Span<T> GetSpan(int sizeHint = 0)

Returns the memory to write to that is at least the requested size.