ComponentStreamWriter Class

The writable end of a stream held by the host: the host writes values that a component reads.

public sealed class ComponentStreamWriter : IDisposable
Implements

Properties

NameDescription
IsReaderDroppedGets whether the reader dropped its end: no more values can be written.
ReaderDroppedTokenGets a token that is cancelled when the reader drops its end, such as to stop an operation of the host that produces the values (the reception of a socket). The token is cancelled on the thread of the store.

IsReaderDropped

ComponentStreams.cs

Gets whether the reader dropped its end: no more values can be written.

public bool IsReaderDropped { get; }

Property value

bool

ReaderDroppedToken

ComponentStreams.cs

Gets a token that is cancelled when the reader drops its end, such as to stop an operation of the host that produces the values (the reception of a socket). The token is cancelled on the thread of the store.

public CancellationToken ReaderDroppedToken { get; }

Property value

CancellationToken

Methods

NameDescription
Create(ComponentValueType?, ComponentValue)Creates a stream: the host writes to the writer, and gives the readable end to a component.
Dispose()Drops the writable end: the reader reads the end of the stream.
WriteAsync(ComponentValue[], CancellationToken)Writes values: returns the number of values the reader read, which is less than the count when the reader dropped its end.
WriteAsync(ReadOnlyMemory<byte>, CancellationToken)Writes bytes to a stream<u8>: returns the number of bytes the reader read.

Create(ComponentValueType?, ComponentValue)

ComponentStreams.cs

Creates a stream: the host writes to the writer, and gives the readable end to a component.

public static ComponentStreamWriter Create(ComponentValueType? elementType, out ComponentValue readable)

Parameters

elementType ComponentValueType?
The type of the elements, or null.
readable ComponentValue
The readable end, to give to a component as a value of type stream.

Returns

ComponentStreamWriter

Drops the writable end: the reader reads the end of the stream.

public void Dispose()

WriteAsync overloads

WriteAsync(ComponentValue[], CancellationToken)

ComponentStreams.cs

Writes values: returns the number of values the reader read, which is less than the count when the reader dropped its end.

net10.0

public ValueTask<int> WriteAsync(ComponentValue[] values, CancellationToken cancellationToken = default)

net11.0

public ValueTask<int> WriteAsync(ComponentValue[] values, CancellationToken cancellationToken = default)
Parameters
values ComponentValue[]
cancellationToken CancellationToken
Returns

ValueTask<int>

WriteAsync(ReadOnlyMemory<byte>, CancellationToken)

ComponentStreams.cs

Writes bytes to a stream<u8>: returns the number of bytes the reader read.

public ValueTask<int> WriteAsync(ReadOnlyMemory<byte> bytes, CancellationToken cancellationToken = default)
Parameters
bytes ReadOnlyMemory<byte>
cancellationToken CancellationToken
Returns

ValueTask<int>