Table of Contents

Struct Chunk<T>

Namespace
Excalibur.Dispatch.Streaming
Assembly
Excalibur.Dispatch.Abstractions.dll

Represents a single chunk within a streamed sequence, providing positional metadata.

public readonly record struct Chunk<T> : IEquatable<Chunk<T>>

Type Parameters

T

The type of data contained in the chunk.

Implements
Inherited Members
Extension Methods

Remarks

Chunk<T> is a lightweight, stack-allocated value type designed for high-performance streaming scenarios. It wraps individual data items with positional metadata that enables:

  • First/last chunk detection for initialization and finalization logic
  • Zero-based indexing for progress tracking and ordered processing
  • Efficient memory usage through readonly struct semantics

This type is intended for use with IAsyncEnumerable<T> streams where handlers need to know their position within the overall sequence without buffering.

Constructors

Chunk(T, long, bool, bool)

Represents a single chunk within a streamed sequence, providing positional metadata.

public Chunk(T Data, long Index, bool IsFirst, bool IsLast)

Parameters

Data T

The data payload for this chunk.

Index long

The zero-based position of this chunk within the stream.

IsFirst bool

true if this is the first chunk in the stream; otherwise, false.

IsLast bool

true if this is the last chunk in the stream; otherwise, false.

Remarks

Chunk<T> is a lightweight, stack-allocated value type designed for high-performance streaming scenarios. It wraps individual data items with positional metadata that enables:

  • First/last chunk detection for initialization and finalization logic
  • Zero-based indexing for progress tracking and ordered processing
  • Efficient memory usage through readonly struct semantics

This type is intended for use with IAsyncEnumerable<T> streams where handlers need to know their position within the overall sequence without buffering.

Properties

Data

The data payload for this chunk.

public T Data { get; init; }

Property Value

T

Index

The zero-based position of this chunk within the stream.

public long Index { get; init; }

Property Value

long

IsFirst

true if this is the first chunk in the stream; otherwise, false.

public bool IsFirst { get; init; }

Property Value

bool

IsLast

true if this is the last chunk in the stream; otherwise, false.

public bool IsLast { get; init; }

Property Value

bool

IsMiddle

Gets a value indicating whether this chunk is neither the first nor the last in the stream.

public bool IsMiddle { get; }

Property Value

bool

true if this chunk is in the middle of the stream; otherwise, false.

IsSingle

Gets a value indicating whether this is the only chunk in the stream.

public bool IsSingle { get; }

Property Value

bool

true if this chunk is both the first and last (single-item stream); otherwise, false.