Table of Contents

Struct SpanStream

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

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

data Span<byte>

The backing byte span; the stream reads from the front and advances the cursor.

Properties

Length

Number of bytes remaining ahead of the cursor.

public int Length { get; }

Property Value

int

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

T

An 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

length int

Number of elements to read.

Returns

Span<T>

A Span<T> aliasing the popped region of the underlying buffer.

Type Parameters

T

An 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

T

An unmanaged element type.