Table of Contents

Class ChunkExtensions

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

Extension methods that attach positional metadata to a stream, producing Chunk<T> values.

public static class ChunkExtensions
Inheritance
ChunkExtensions
Inherited Members

Methods

AsSingleChunk<T>(T)

Presents a single value as a one-element chunked stream.

public static IAsyncEnumerable<Chunk<T>> AsSingleChunk<T>(this T data)

Parameters

data T

The value to wrap.

Returns

IAsyncEnumerable<Chunk<T>>

A stream of exactly one chunk, which is both the first and the last (IsSingle is true).

Type Parameters

T

The value type.

Remarks

Use this where an API requires a chunked stream but the result is known to be a single value, so the caller does not have to hand-construct the positional metadata.

WithChunkInfo<T>(IAsyncEnumerable<T>)

Wraps each element of a stream in a Chunk<T> carrying its position.

public static IAsyncEnumerable<Chunk<T>> WithChunkInfo<T>(this IAsyncEnumerable<T> source)

Parameters

source IAsyncEnumerable<T>

The stream to annotate.

Returns

IAsyncEnumerable<Chunk<T>>

A stream of chunks, each describing its own position within the sequence.

Type Parameters

T

The element type.

Exceptions

ArgumentNullException

source is null.

WithChunkInfo<T>(IAsyncEnumerable<T>, CancellationToken)

Wraps each element of a stream in a Chunk<T> carrying its position.

public static IAsyncEnumerable<Chunk<T>> WithChunkInfo<T>(this IAsyncEnumerable<T> source, CancellationToken cancellationToken)

Parameters

source IAsyncEnumerable<T>

The stream to annotate.

cancellationToken CancellationToken

A token that cancels enumeration.

Returns

IAsyncEnumerable<Chunk<T>>

A stream of chunks, each describing its own position within the sequence.

Type Parameters

T

The element type.

Remarks

The source is read one element ahead so that each chunk can report whether it is the last. An empty source yields no chunks; a single-element source yields one chunk that is both first and last (IsSingle).

Exceptions

ArgumentNullException

source is null.