Show / Hide Table of Contents

Interface IGrowableBuffer<T>

Represents common interface for growable buffer writers.

Inherited Members
IReadOnlySpanConsumer<T>.Invoke(ReadOnlySpan<T>)
ISupplier<ReadOnlyMemory<T>, CancellationToken, ValueTask>.Invoke(ReadOnlyMemory<T>, CancellationToken)
IFunctional<Func<ReadOnlyMemory<T>, CancellationToken, ValueTask>>.ToDelegate()
IDisposable.Dispose()
IResettable.Reset()
Namespace: DotNext.Buffers
Assembly: DotNext.dll
Syntax
public interface IGrowableBuffer<T> : IReadOnlySpanConsumer<T>, ISupplier<ReadOnlyMemory<T>, CancellationToken, ValueTask>, IFunctional<Func<ReadOnlyMemory<T>, CancellationToken, ValueTask>>, 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

| Edit this page View Source

Capacity

Gets the maximum number of elements that can hold this buffer.

Declaration
long? Capacity { get; }
Property Value
Type Description
long?

The maximum number of elements; or null if this buffer has no limits.

| Edit this page 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

| Edit this page View Source

Clear()

Clears the contents of the writer.

Declaration
void Clear()
Exceptions
Type Condition
ObjectDisposedException

The writer has been disposed.

| Edit this page 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.

| Edit this page 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.

| Edit this page View Source

CopyTo<TConsumer>(TConsumer)

Passes the contents of this writer to the callback.

Declaration
void CopyTo<TConsumer>(TConsumer consumer) where TConsumer : IReadOnlySpanConsumer<T>
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.

| Edit this page 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.

| Edit this page 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.

| Edit this page 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.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾