Interface IGrowableBuffer<T>
Represents common interface for growable buffer writers.
Inherited Members
Namespace: DotNext.Buffers
Assembly: DotNext.dll
Syntax
public interface IGrowableBuffer<T> : IBufferWriter<T>, IConsumer<ReadOnlySpan<T>>, ISupplier<ReadOnlyMemory<T>, CancellationToken, ValueTask>, IFunctional, IDisposable, IResettable
Type Parameters
| Name | Description |
|---|---|
| T | The type of the elements in the buffer. |
Remarks
This interface is intended to describe the shape of all buffer writer types in .NEXT family of libraries. It is not recommended to have custom implementation of this interface in your code.
Properties
View SourceWrittenCount
Gets the number of written elements.
Declaration
long WrittenCount { get; }
Property Value
| Type | Description |
|---|---|
| long |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | The writer has been disposed. |
Methods
View SourceCopyTo(Span<T>)
Copies the contents of this writer to the specified memory block.
Declaration
int CopyTo(Span<T> output)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<T> | output | The memory block to be modified. |
Returns
| Type | Description |
|---|---|
| int | The actual number of copied elements. |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | The builder has been disposed. |
CopyToAsync<TConsumer>(TConsumer, CancellationToken)
Passes the contents of this writer to the callback asynchronously.
Declaration
ValueTask CopyToAsync<TConsumer>(TConsumer consumer, CancellationToken token) where TConsumer : ISupplier<ReadOnlyMemory<T>, CancellationToken, ValueTask>
Parameters
| Type | Name | Description |
|---|---|---|
| TConsumer | consumer | The callback used to accept the memory representing the contents of this builder. |
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask | The task representing asynchronous execution of this method. |
Type Parameters
| Name | Description |
|---|---|
| TConsumer | The type of the consumer. |
Remarks
The callback may be called multiple times.
CopyTo<TConsumer>(TConsumer)
Passes the contents of this writer to the callback.
Declaration
void CopyTo<TConsumer>(TConsumer consumer) where TConsumer : IConsumer<ReadOnlySpan<T>>, allows ref struct
Parameters
| Type | Name | Description |
|---|---|---|
| TConsumer | consumer | The callback used to accept the memory representing the contents of this builder. |
Type Parameters
| Name | Description |
|---|---|
| TConsumer | The type of the object that represents the consumer. |
Remarks
The callback may be called multiple times.
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | The writer has been disposed. |
TryGetWrittenContent(out ReadOnlyMemory<T>)
Attempts to get written content as contiguous block of memory.
Declaration
bool TryGetWrittenContent(out ReadOnlyMemory<T> block)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlyMemory<T> | block | The block representing written content. |
Returns
| Type | Description |
|---|---|
| bool | true if the written content can be represented as contiguous block of memory; otherwise, false. |
Write(ReadOnlySpan<T>)
Writes the memory block.
Declaration
void Write(ReadOnlySpan<T> input)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<T> | input | The memory block to be written. |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | The writer has been disposed. |
Write(T)
Writes single element to this buffer.
Declaration
void Write(T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value to be written. |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | The writer has been disposed. |