Show / Hide Table of Contents

Interface IGrowableBuffer<T>

Represents common interface for growable buffer writers.

Inherited Members
IBufferWriter<T>.Advance(int)
IBufferWriter<T>.GetMemory(int)
IBufferWriter<T>.GetSpan(int)
IConsumer<ReadOnlySpan<T>>.Invoke(ReadOnlySpan<T>)
ISupplier<ReadOnlyMemory<T>, CancellationToken, ValueTask>.Invoke(ReadOnlyMemory<T>, CancellationToken)
IFunctional.DynamicInvoke(scoped ref readonly Variant, int, scoped Variant)
IFunctional.GetArgument<T>(ref readonly Variant, int)
IDisposable.Dispose()
IResettable.Reset()
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 Source

WrittenCount

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 Source

CopyTo(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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

View Source

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.

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾