Skip to content

PooledBuffer Methods

A System.Buffers.IBufferWriter implementation implemented using pooled arrays which is specialized for creating System.Buffers.ReadOnlySequence instances.

Advance(int)

View source
public void Advance(int bytes)
Notifies the System.Buffers.IBufferWriter that count data items were written to the output System.Span or System.Memory.

Parameters

bytesint
The number of data items written to the System.Span or System.Memory.

AsReadOnlySequence

View source
public ReadOnlySequence<byte> AsReadOnlySequence()
Returns a new System.Buffers.ReadOnlySequence which must not be accessed after disposing this instance.

CopyTo(Span<byte>)

View source
public readonly void CopyTo(Span<byte> output)
Copies the contents of this writer to a span.

Parameters

outputSpan<byte>

CopyTo(TBufferWriter)

View source
public readonly void CopyTo<TBufferWriter>(ref TBufferWriter writer)
Copies the contents of this writer to another writer.

Parameters

writerTBufferWriter

CopyTo(Writer<TBufferWriter>)

View source
public readonly void CopyTo<TBufferWriter>(ref Writer<TBufferWriter> writer)
Copies the contents of this writer to another writer.

Parameters

writerWriter<TBufferWriter>

Dispose

View source
public void Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

GetMemory(int)

View source
public Memory<byte> GetMemory(int sizeHint = 0)
Returns a System.Memory to write to that is at least the requested size (specified by sizeHint).

Parameters

sizeHintint
The minimum length of the returned System.Memory. If 0, a non-empty buffer is returned.

Returns

A System.Memory of at least the size sizeHint. If sizeHint is 0, returns a non-empty buffer.

Exceptions

System.OutOfMemoryException
The requested buffer size is not available.

GetSpan(int)

View source
public Span<byte> GetSpan(int sizeHint = 0)
Returns a System.Span to write to that is at least the requested size (specified by sizeHint).

Parameters

sizeHintint
The minimum length of the returned System.Span. If 0, a non-empty buffer is returned.

Returns

A System.Span of at least the size sizeHint. If sizeHint is 0, returns a non-empty buffer.

Reset

View source
public void Reset()
Resets this instance, returning all memory.

Slice(int)

View source
public readonly BufferSlice Slice(int offset)
Returns a slice of this buffer, beginning at the specified offset.

Parameters

offsetint

Returns

A slice representing a subset of this instance, beginning at the specified offset.

Slice(int, int)

View source
public readonly BufferSlice Slice(int offset, int length)
Returns a slice of this buffer, beginning at the specified offset and having the specified length.

Parameters

offsetint
lengthint

Returns

A slice representing a subset of this instance, beginning at the specified offset.

ToArray

View source
public readonly byte[] ToArray()
Returns the data which has been written as an array.

Returns

The data which has been written.