DotNext by Roman Sakno

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

 SpanReader<T>

public struct SpanReader<T>
Represents simple memory reader backed by ReadOnlySpan<T>.
public int ConsumedCount { get; }

Gets the number of consumed elements.

public ReadOnlySpan<T> ConsumedSpan { get; }

Gets the span over consumed elements.

public T& modreq(System.Runtime.InteropServices.InAttribute) Current { get; }

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

public int RemainingCount { get; }

Gets the number of unread elements.

public ReadOnlySpan<T> Span { get; }

Gets underlying span.

public SpanReader(ReadOnlySpan<T> span)

Initializes a new memory reader.

public int Read(Span<T> output)

Copies elements from the underlying span.

public T Read()

Reads single element from the underlying span.

public ReadOnlySpan<T> Read(int count)

Reads the portion of data from the underlying span.

public ReadOnlySpan<T> ReadToEnd()

Reads the rest of the memory block.

public void Reset()

Sets reader position to the first element.

public bool TryRead(Span<T> output)

Copies elements from the underlying span.

public bool TryRead(int count, out ReadOnlySpan result)

Reads the portion of data from the underlying span.

public bool TryRead(out T result)

Reads single element from the underlying span.