Edit

Share via


PrefixingBufferWriter<T,TBufferWriter> Class

Definition

An IBufferWriter<T> that reserves some fixed size for a header.

public class PrefixingBufferWriter<T,TBufferWriter> : System.Buffers.IBufferWriter<T> where TBufferWriter : IBufferWriter<T>
type PrefixingBufferWriter<'T, 'BufferWriter (requires 'BufferWriter :> IBufferWriter<'T>)> = class
    interface IBufferWriter<'T>
Public Class PrefixingBufferWriter(Of T, TBufferWriter)
Implements IBufferWriter(Of T)

Type Parameters

T

The type of element written by this writer.

TBufferWriter

The type of underlying buffer writer.

Inheritance
PrefixingBufferWriter<T,TBufferWriter>
Implements

Remarks

This type is used for inserting the length of list in the header when the length is not known beforehand. It is optimized to minimize or avoid copying.

Constructors

PrefixingBufferWriter<T,TBufferWriter>(Int32, Int32, MemoryPool<T>)

Initializes a new instance of the PrefixingBufferWriter<T,TBufferWriter> class.

Properties

CommittedBytes

Methods

Advance(Int32)

Notifies the IBufferWriter<T> that count data items were written to the output Span<T> or Memory<T>.

Complete(ReadOnlySpan<T>)

Inserts the prefix and commits the payload to the underlying IBufferWriter<T>.

GetMemory(Int32)

Returns a Memory<T> to write to that is at least the requested size (specified by sizeHint).

GetSpan(Int32)

Returns a Span<T> to write to that is at least the requested size (specified by sizeHint).

Reset(TBufferWriter)

Resets this instance to a reusable state.

Applies to