Class PointerExtensions
Extensions for Pointer<T> data type.
Inherited Members
Namespace: DotNext.IO
Assembly: DotNext.Unsafe.dll
Syntax
public static class PointerExtensions
Methods
View SourceCreate<T>(Pointer<T>, long, FileAccess)
Returns representation of the memory identified by this pointer in the form of the stream.
Declaration
public static Stream Create<T>(Pointer<T> source, long count, FileAccess access = FileAccess.ReadWrite) where T : unmanaged
Parameters
| Type | Name | Description |
|---|---|---|
| Pointer<T> | source | The source pointer that points to the data to be wrapped by the stream. |
| long | count | The number of elements of type |
| FileAccess | access | The type of the access supported by the returned stream. |
Returns
| Type | Description |
|---|---|
| Stream | The stream representing the memory identified by this pointer. |
Type Parameters
| Name | Description |
|---|---|
| T |
Remarks
This method returns Stream compatible over the memory identified by this pointer. No copying is performed.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
ReadFromAsync<T>(Pointer<T>, Stream, long, CancellationToken)
Copies bytes from the given stream to the memory location identified by this pointer asynchronously.
Declaration
public static ValueTask<long> ReadFromAsync<T>(this Pointer<T> receiver, Stream source, long count, CancellationToken token = default) where T : unmanaged
Parameters
| Type | Name | Description |
|---|---|---|
| Pointer<T> | receiver | |
| Stream | source | The source stream. |
| long | count | The number of elements of type |
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<long> | The actual number of copied elements. |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| NullPointerException | This pointer is zero. |
| ArgumentException | The stream is not readable. |
| ArgumentOutOfRangeException |
|
| OperationCanceledException | The operation has been canceled. |
ReadFrom<T>(Pointer<T>, Stream, long)
Copies bytes from the given stream to the memory location identified by this pointer.
Declaration
public static long ReadFrom<T>(this Pointer<T> receiver, Stream source, long count) where T : unmanaged
Parameters
| Type | Name | Description |
|---|---|---|
| Pointer<T> | receiver | |
| Stream | source | The source stream. |
| long | count | The number of elements of type |
Returns
| Type | Description |
|---|---|
| long | The actual number of copied elements. |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| NullPointerException | This pointer is zero. |
| ArgumentException | The stream is not readable. |
| ArgumentOutOfRangeException |
|
WriteToAsync<T>(Pointer<T>, Stream, long, CancellationToken)
Copies bytes from the memory location identified by this pointer to the stream asynchronously.
Declaration
public static ValueTask WriteToAsync<T>(this Pointer<T> receiver, Stream destination, long count, CancellationToken token = default) where T : unmanaged
Parameters
| Type | Name | Description |
|---|---|---|
| Pointer<T> | receiver | |
| Stream | destination | The destination stream. |
| long | count | The number of elements of type |
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask | The task instance representing asynchronous state of the copying process. |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| NullPointerException | This pointer is equal to zero. |
| ArgumentOutOfRangeException |
|
| ArgumentException | The stream is not writable. |
| OperationCanceledException | The operation has been canceled. |
WriteTo<T>(Pointer<T>, Stream, long)
Copies bytes from the memory location identified by this pointer to the stream.
Declaration
[CLSCompliant(false)]
public static void WriteTo<T>(this Pointer<T> receiver, Stream destination, long count) where T : unmanaged
Parameters
| Type | Name | Description |
|---|---|---|
| Pointer<T> | receiver | |
| Stream | destination | The destination stream. |
| long | count | The number of elements of type |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| NullPointerException | This pointer is equal to zero. |
| ArgumentException | The stream is not writable. |
| ArgumentOutOfRangeException |
|