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.GetType()
object.Equals(object, object)
object.ReferenceEquals(object, object)
Namespace: DotNext.Runtime.Caching
Assembly: DotNext.IO.dll
Syntax
public readonly struct DiskSpacePool.Segment : IDisposable, IAsyncDisposable

Methods

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).

View Source

Dispose()

Declaration
public void Dispose()
View Source

DisposeAsync()

Declaration
public ValueTask DisposeAsync()
Returns
Type Description
ValueTask
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.

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.

View Source

ToString()

Declaration
public override string? ToString()
Returns
Type Description
string
Overrides
ValueType.ToString()
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.

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, params ReadOnlySpan<T>)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾