DotNext by .NET Foundation and Contributors

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

 SpanWriter<T>

public struct SpanWriter<T>
Represents simple memory writer backed by Span<T>.
public ref T Current { get; }

Gets the element at the current position in the underlying memory block.

public int FreeCapacity { get; }

Gets the available space in the underlying span.

public Span<T> RemainingSpan { get; }

Gets the remaining part of the span.

public Span<T> Span { get; }

Gets underlying span.

public int WrittenCount { get; }

Gets the number of occupied elements in the underlying span.

public Span<T> WrittenSpan { get; }

Gets the span over written elements.

public SpanWriter(Span<T> span)

Initializes a new memory writer.

public SpanWriter(ref T reference, int length)

Initializes a new memory writer.

public void Add(T item)

Puts single element into the underlying span.

public void Advance(int count)

Advances the position of this writer.

public void Reset()

Sets writer position to the first element.

public void Rewind(int count)

Moves the writer back the specified number of items.

public Span<T> Slide(int count)

Obtains the portion of underlying span and marks it as written.

public bool TryAdd(T item)

Puts single element into the underlying span.

public bool TrySlide(int count, out Span segment)

Obtains the portion of underlying span and marks it as written.

public bool TryWrite(ReadOnlySpan<T> input)

Copies the elements to the underlying span.

public bool TryWrite<TArg>(method action, TArg arg)

public int Write(ReadOnlySpan<T> input)

Copies the elements to the underlying span.

public void Write<TArg>(method action, TArg arg, int count)