Show / Hide Table of Contents

Struct DiskSpacePool.Segment

Provides the random access to the data within the segment.

Implements
IDisposable
IAsyncDisposable
Inherited Members
ValueType.Equals(object)
ValueType.GetHashCode()
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: DotNext.Runtime.Caching
Assembly: DotNext.IO.dll
Syntax
public readonly struct DiskSpacePool.Segment : IDisposable, IAsyncDisposable

Methods

| Edit this page View Source

CreateStream()

Creates a stream representing this segment.

Declaration
public Stream CreateStream()
Returns
Type Description
Stream

A stream representing this segment.

Remarks

The returned stream has a length equal to MaxSegmentSize. You can adjust it by calling SetLength(long).

| Edit this page View Source

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Declaration
public void Dispose()
| Edit this page View Source

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

Declaration
public ValueTask DisposeAsync()
Returns
Type Description
ValueTask

A task that represents the asynchronous dispose operation.

| Edit this page View Source

Read(Span<byte>, int)

Reads the data from the segment at the specified offset.

Declaration
public int Read(Span<byte> buffer, int offset = 0)
Parameters
Type Name Description
Span<byte> buffer

The buffer to be modified with the data from the segment.

int offset

The offset within the segment.

Returns
Type Description
int

The number of bytes written to buffer.

Exceptions
Type Condition
ArgumentOutOfRangeException

offset is negative or larger than MaxSegmentSize.

ObjectDisposedException

The segment has been returned to the pool.

| Edit this page View Source

ReadAsync(Memory<byte>, int, CancellationToken)

Reads the data from the segment at the specified offset.

Declaration
public ValueTask<int> ReadAsync(Memory<byte> buffer, int offset = 0, CancellationToken token = default)
Parameters
Type Name Description
Memory<byte> buffer

The buffer to be modified with the data from the segment.

int offset

The offset within the segment.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<int>

The number of bytes written to buffer.

Exceptions
Type Condition
ArgumentOutOfRangeException

offset is negative or larger than MaxSegmentSize.

ObjectDisposedException

The segment has been returned to the pool.

OperationCanceledException

The operation has been canceled.

| Edit this page View Source

ToString()

Returns the fully qualified type name of this instance.

Declaration
public override string? ToString()
Returns
Type Description
string

The fully qualified type name.

Overrides
ValueType.ToString()
| Edit this page View Source

Write(ReadOnlySpan<byte>, int)

Writes to the segment at the specified offset.

Declaration
public void Write(ReadOnlySpan<byte> buffer, int offset = 0)
Parameters
Type Name Description
ReadOnlySpan<byte> buffer

The data to be written.

int offset

The offset within the segment.

Exceptions
Type Condition
ObjectDisposedException

The segment has been returned to the pool.

ArgumentOutOfRangeException

offset is negative; or buffer is too large.

| Edit this page View Source

WriteAsync(ReadOnlyMemory<byte>, int, CancellationToken)

Writes to the segment at the specified offset.

Declaration
public ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, int offset = 0, CancellationToken token = default)
Parameters
Type Name Description
ReadOnlyMemory<byte> buffer

The data to be written.

int offset

The offset within the segment.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask
Exceptions
Type Condition
ObjectDisposedException

The segment has been returned to the pool.

ArgumentOutOfRangeException

offset is negative; or buffer is too large.

OperationCanceledException

The operation has been canceled.

Implements

IDisposable
IAsyncDisposable

Extension Methods

BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
Collection.ToAsyncEnumerator<TEnumerator, T>(TEnumerator, CancellationToken)
Collection.ToClassicEnumerator<TEnumerator, T>(TEnumerator)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
ExpressionBuilder.Const<T>(T)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾