Struct SpanStream
A forward-only cursor over a Span<T> of bytes: each Pop reads a value (or sub-span) from the front and advances past it. A
ref struct, so it lives on the stack and cannot outlive the span it wraps. No bounds checking — the caller must not read
past the end.
public ref struct SpanStream
- Inherited Members
Constructors
SpanStream(Span<byte>)
Wraps data as a forward-only byte cursor positioned at its start.
public SpanStream(Span<byte> data)
Parameters
Properties
Length
Number of bytes remaining ahead of the cursor.
public int Length { get; }
Property Value
Methods
PopRef<T>()
Reads one T from the front as a ref into the underlying buffer and advances past it.
public ref T PopRef<T>() where T : unmanaged
Returns
- T
A writable reference to the popped value within the buffer.
Type Parameters
TAn unmanaged element type.
PopSpan<T>(int)
Reads length elements of T from the front and advances past them.
public Span<T> PopSpan<T>(int length = 1) where T : unmanaged
Parameters
lengthintNumber of elements to read.
Returns
Type Parameters
TAn unmanaged element type.
Pop<T>()
Reads and returns one T by value from the front, advancing past it.
public T Pop<T>() where T : unmanaged
Returns
- T
The popped value.
Type Parameters
TAn unmanaged element type.