Table of Contents

Method Slice

Namespace
NATS.Client.Core
Assembly
NATS.Client.Core.dll

Slice(int, int)

Slices the buffer currently in use and returns a new NatsMemoryOwner<T> instance.

public NatsMemoryOwner<T> Slice(int start, int length)

Parameters

start int

The starting offset within the current buffer.

length int

The length of the buffer to use.

Returns

NatsMemoryOwner<T>

A new NatsMemoryOwner<T> instance using the target range of items.

Remarks

Using this method will dispose the current instance, and should only be used when an oversized buffer is rented and then adjusted in size, to avoid having to rent a new buffer of the new size and copy the previous items into the new one, or needing an additional variable/field to manually handle to track the used range within a given NatsMemoryOwner<T> instance.

Exceptions

ObjectDisposedException

Thrown when the buffer in use has already been disposed.

ArgumentOutOfRangeException

Thrown when start or length are not valid.