MemoryBufferWriter<T> Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents an output sink into which T data can be written, backed by a Memory<T> instance.
public sealed class MemoryBufferWriter<T> : CommunityToolkit.HighPerformance.Buffers.IBuffer<T>, System.Buffers.IBufferWriter<T>
type MemoryBufferWriter<'T> = class
interface IBuffer<'T>
interface IBufferWriter<'T>
Public NotInheritable Class MemoryBufferWriter(Of T)
Implements IBuffer(Of T), IBufferWriter(Of T)
Type Parameters
- T
The type of items to write to the current instance.
- Inheritance
-
MemoryBufferWriter<T>
- Implements
Remarks
This is a custom IBufferWriter<T> implementation that wraps a Memory<T> instance. It can be used to bridge APIs consuming an IBufferWriter<T> with existing Memory<T> instances (or objects that can be converted to a Memory<T>), to ensure the data is written directly to the intended buffer, with no possibility of doing additional allocations or expanding the available capacity.
Constructors
| MemoryBufferWriter<T>(Memory<T>) |
Initializes a new instance of the MemoryBufferWriter<T> class. |
Properties
| Capacity |
Gets the total amount of space within the underlying buffer. |
| FreeCapacity |
Gets the amount of space available that can still be written into without forcing the underlying buffer to grow. |
| WrittenCount |
Gets the amount of data written to the underlying buffer so far. |
| WrittenMemory |
Gets the data written to the underlying buffer so far, as a ReadOnlyMemory<T>. |
| WrittenSpan |
Gets the data written to the underlying buffer so far, as a ReadOnlySpan<T>. |
Methods
| Advance(Int32) | Notifies the IBufferWriter<T> that |
| Clear() |
Clears the data written to the underlying buffer. |
| GetMemory(Int32) | Returns a Memory<T> to write to that is at least the requested size (specified by |
| GetSpan(Int32) | Returns a Span<T> to write to that is at least the requested size (specified by |
| ToString() |
Returns a string that represents the current object. |
Extension Methods
| Write<T>(IBufferWriter<T>, T) |
Writes a value of a specified type into a target IBufferWriter<T> instance. |
| Write<T>(IBufferWriter<T>, ReadOnlySpan<T>) | |
| Write<T>(IBufferWriter<T>, T) |
Writes a value of a specified type into a target IBufferWriter<T> instance. |