ChannelTextReader
A TextReader backed by a Channel<T> that supports both char-level reads (ReadAsync(Memory<char>, CancellationToken)) and line-level reads (ReadLineAsync(CancellationToken)). Transport code pushes raw text via Enqueue(string); the reader handles internal buffering and newline parsing.
- Kind:
Class - Namespace: Repl
- Assembly:
Repl.Defaults - Source: src/Repl.Defaults/ChannelTextReader.cs
Signature
Section titled “Signature”public sealed class ChannelTextReader : TextReader, IDisposableInheritance
Section titled “Inheritance”Implements
Section titled “Implements”Methods
Section titled “Methods”Complete()
Section titled “Complete()”Signals that no more input will arrive (EOF).
public void Complete()Enqueue(string)
Section titled “Enqueue(string)”Pushes a raw text chunk from the transport layer.
public void Enqueue(string text)Parameters
Section titled “Parameters”text(string): Text to enqueue.
ReadAsync(Memory<char>, CancellationToken)
Section titled “ReadAsync(Memory<char>, CancellationToken)”Reads characters into buffer, returning the number of characters read.
Returns 0 when the channel is completed and no buffered data remains.
This method is used by VtProbe for char-level terminal detection.
public override ValueTask<int> ReadAsync(Memory<char> buffer, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”buffer(Memory<char>)cancellationToken(CancellationToken)
Returns
Section titled “Returns”ValueTask<int>
ReadLineAsync(CancellationToken)
Section titled “ReadLineAsync(CancellationToken)”Reads a complete line, accumulating across chunks until a line terminator is found.
Returns null when the channel is completed and no buffered data remains.
public override ValueTask<string?> ReadLineAsync(CancellationToken cancellationToken)Parameters
Section titled “Parameters”cancellationToken(CancellationToken)
Returns
Section titled “Returns”ValueTask<string>