Struct DiskSpacePool.Segment
Provides the random access to the data within the segment.
Inherited Members
Namespace: DotNext.Runtime.Caching
Assembly: DotNext.IO.dll
Syntax
public readonly struct DiskSpacePool.Segment : IDisposable, IAsyncDisposable
Methods
| Edit this page View SourceCreateStream()
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).
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
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. |
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 |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ObjectDisposedException | The segment has been returned to the pool. |
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 |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ObjectDisposedException | The segment has been returned to the pool. |
OperationCanceledException | The operation has been canceled. |
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
| Edit this page View SourceWrite(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 |
|
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 |
|
OperationCanceledException | The operation has been canceled. |