<PackageReference Include="System.IO.Pipelines" Version="9.0.10" />

PipeReader

public abstract class PipeReader
Defines a class that provides access to a read side of pipe.
protected PipeReader()

Initializes a new instance of the PipeReader class.

public static PipeReader Create(Stream stream, StreamPipeReaderOptions readerOptions = null)

Creates a PipeReader wrapping the specified Stream.

public static PipeReader Create(ReadOnlySequence<byte> sequence)

Creates a PipeReader wrapping the specified ReadOnlySequence<T>.

public abstract void AdvanceTo(SequencePosition consumed)

Moves forward the pipeline's read cursor to after the consumed data, marking the data as processed.

public abstract void AdvanceTo(SequencePosition consumed, SequencePosition examined)

Moves forward the pipeline's read cursor to after the consumed data, marking the data as processed, read and examined.

public virtual Stream AsStream(bool leaveOpen = false)

Returns a Stream representation of the PipeReader.

public abstract void CancelPendingRead()

Cancels the pending ReadAsync operation without causing it to throw and without completing the PipeReader. If there is no pending operation, this cancels the next operation.

public abstract void Complete(Exception exception = null)

Signals to the producer that the consumer is done reading.

public virtual ValueTask CompleteAsync(Exception exception = null)

Marks the current pipe reader instance as being complete, meaning no more data will be read from it.

public virtual Task CopyToAsync(PipeWriter destination, CancellationToken cancellationToken = default)

Asynchronously reads the bytes from the PipeReader and writes them to the specified PipeWriter, using a specified cancellation token.

public virtual Task CopyToAsync(Stream destination, CancellationToken cancellationToken = default)

Asynchronously reads the bytes from the PipeReader and writes them to the specified stream, using a specified cancellation token.

public virtual void OnWriterCompleted(Action<Exception, object> callback, object state)

Registers a callback that executes when the PipeWriter side of the pipe is completed.

public abstract ValueTask<ReadResult> ReadAsync(CancellationToken cancellationToken = default)

Asynchronously reads a sequence of bytes from the current PipeReader.

public ValueTask<ReadResult> ReadAtLeastAsync(int minimumSize, CancellationToken cancellationToken = default)

Asynchronously reads a sequence of bytes from the current PipeReader.

protected virtual ValueTask<ReadResult> ReadAtLeastAsyncCore(int minimumSize, CancellationToken cancellationToken)

Asynchronously reads a sequence of bytes from the current PipeReader.

public abstract bool TryRead(out ReadResult result)

Attempts to synchronously read data the PipeReader.