Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​IO.​Pipelines.​PipeReader

Assembly: System.IO.Pipelines

Inheritance: object → PipeReader

Defines a class that provides access to a read side of pipe.

Methods

public void
AdvanceTo​(SequencePosition consumed)
Moves forward the pipeline's read cursor to after the consumed data, marking the data as processed.
consumed Marks the extent of the data that has been successfully processed.
public 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.
consumed Marks the extent of the data that has been successfully processed.
examined Marks the extent of the data that has been read and examined.
public Stream
AsStream​(bool leaveOpen = false)
Returns a <see cref="T:System.IO.Stream" /> representation of the <see cref="T:System.IO.Pipelines.PipeReader" /> .
Returns A stream that represents the <see cref="T:System.IO.Pipelines.PipeReader" /> .
leaveOpen An optional flag that indicates whether disposing the returned <see cref="T:System.IO.Stream" /> leaves <see cref="T:System.IO.Pipelines.PipeReader" /> open ( <see langword="true" /> ) or completes <see cref="T:System.IO.Pipelines.PipeReader" /> ( <see langword="false" /> ).
public void
CancelPendingRead​()
Cancels the pending <see cref="M:System.IO.Pipelines.PipeReader.ReadAsync(System.Threading.CancellationToken)" /> operation without causing it to throw and without completing the <see cref="T:System.IO.Pipelines.PipeReader" /> . If there is no pending operation, this cancels the next operation.
public void
Complete​(Exception exception = null)
Signals to the producer that the consumer is done reading.
exception Optional <see cref="T:System.Exception" /> indicating a failure that's causing the pipeline to complete.
CompleteAsync​(Exception exception = null)
Marks the current pipe reader instance as being complete, meaning no more data will be read from it.
Returns A value task that represents the asynchronous complete operation.
exception An optional exception that indicates the failure that caused the reader to complete.
CopyToAsync​(PipeWriter destination, Threading.​CancellationToken cancellationToken = null)
Asynchronously reads the bytes from the <see cref="T:System.IO.Pipelines.PipeReader" /> and writes them to the specified <see cref="T:System.IO.Pipelines.PipeWriter" /> , using a specified cancellation token.
Returns A task that represents the asynchronous copy operation.
destination The pipe writer to which the contents of the current stream will be copied.
cancellationToken The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
CopyToAsync​(Stream destination, Threading.​CancellationToken cancellationToken = null)
Asynchronously reads the bytes from the <see cref="T:System.IO.Pipelines.PipeReader" /> and writes them to the specified stream, using a specified cancellation token.
Returns A task that represents the asynchronous copy operation.
destination The stream to which the contents of the current stream will be copied.
cancellationToken The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
public static PipeReader
Create​(Buffers.​ReadOnlySequence<​byte> sequence)
Creates a <see cref="T:System.IO.Pipelines.PipeReader" /> wrapping the specified <see cref="T:System.Buffers.ReadOnlySequence`1" /> .
Returns A <see cref="T:System.IO.Pipelines.PipeReader" /> that wraps the <see cref="T:System.Buffers.ReadOnlySequence`1" /> .
sequence The sequence to wrap.
public static PipeReader
Create​(Stream stream, StreamPipeReaderOptions? readerOptions = null)
Creates a <see cref="T:System.IO.Pipelines.PipeReader" /> wrapping the specified <see cref="T:System.IO.Stream" /> .
Returns A <see cref="T:System.IO.Pipelines.PipeReader" /> that wraps the <see cref="T:System.IO.Stream" /> .
stream The stream that the pipe reader will wrap.
readerOptions The options to configure the pipe reader.
public void
OnWriterCompleted​(Action<​Exception, object> callback, object state)
Registers a callback that executes when the <see cref="T:System.IO.Pipelines.PipeWriter" /> side of the pipe is completed.
callback The callback to register.
state The state object to pass to <paramref name="callback" /> when it's invoked.
ReadAsync​(Threading.​CancellationToken cancellationToken = null)
Asynchronously reads a sequence of bytes from the current <see cref="T:System.IO.Pipelines.PipeReader" /> .
Returns A <see cref="T:System.Threading.Tasks.ValueTask`1" /> representing the asynchronous read operation.
cancellationToken The token to monitor for cancellation requests. The default value is <see langword="default" /> .
ReadAtLeastAsync​(int minimumSize, Threading.​CancellationToken cancellationToken = null)
Asynchronously reads a sequence of bytes from the current <see cref="T:System.IO.Pipelines.PipeReader" /> .
Returns A <see cref="T:System.Threading.Tasks.ValueTask`1" /> representing the asynchronous read operation.
minimumSize The minimum length that needs to be buffered in order for the call to return.
cancellationToken The token to monitor for cancellation requests. The default value is <see langword="default" /> .
ReadAtLeastAsyncCore​(int minimumSize, Threading.​CancellationToken cancellationToken)
Asynchronously reads a sequence of bytes from the current <see cref="T:System.IO.Pipelines.PipeReader" /> .
Returns A <see cref="T:System.Threading.Tasks.ValueTask`1" /> representing the asynchronous read operation.
minimumSize The minimum length that needs to be buffered in order for the call to return.
cancellationToken The token to monitor for cancellation requests. The default value is <see langword="default" /> .
public bool
TryRead​(ReadResult& result)
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object