Interface IUnmanagedMemory
Represents common interface for the wrapper of the unmanaged memory.
Inherited Members
Namespace: DotNext.Runtime.InteropServices
Assembly: DotNext.Unsafe.dll
Syntax
public interface IUnmanagedMemory : IDisposable, IConvertible<Stream>
Properties
| Improve this Doc View SourceBytes
Gets a span of bytes from the current instance.
Declaration
Span<byte> Bytes { get; }
Property Value
Type | Description |
---|---|
Span<Byte> |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory has been released. |
Pointer
Gets a pointer to the allocated unmanaged memory.
Declaration
Pointer<byte> Pointer { get; }
Property Value
Type | Description |
---|---|
Pointer<Byte> |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory has been released. |
Size
Gets size of referenced unmanaged memory, in bytes.
Declaration
long Size { get; }
Property Value
Type | Description |
---|---|
Int64 |
Methods
| Improve this Doc View SourceAsStream()
Represents unmanaged memory as stream.
Declaration
Stream AsStream()
Returns
Type | Description |
---|---|
Stream | The stream of unmanaged memory. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory has been released. |
BitwiseCompare(IUnmanagedMemory)
Bitwise comparison of the memory blocks.
Declaration
virtual int BitwiseCompare(IUnmanagedMemory other)
Parameters
Type | Name | Description |
---|---|---|
IUnmanagedMemory | other | The block of memory to be compared. |
Returns
Type | Description |
---|---|
Int32 | Comparison result which has the semantics as return type of CompareTo(Object). |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory has been released. |
BitwiseEquals(IUnmanagedMemory)
Computes bitwise equality between two blocks of memory.
Declaration
virtual bool BitwiseEquals(IUnmanagedMemory other)
Parameters
Type | Name | Description |
---|---|---|
IUnmanagedMemory | other | The block of memory to be compared. |
Returns
Type | Description |
---|---|
Boolean | true, if both memory blocks have the same bytes; otherwise, false. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory has been released. |
Clear()
Sets all bits of allocated memory to zero.
Declaration
virtual void Clear()
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory has been released. |
ReadFrom(Pointer<Byte>)
Copies bytes from the source memory to the memory identified by this object.
Declaration
virtual void ReadFrom(Pointer<byte> source)
Parameters
Type | Name | Description |
---|---|---|
Pointer<Byte> | source | The pointer to the source unmanaged memory. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory has been released. |
ReadFrom(Stream)
Copies bytes from the given stream to the memory location identified by this object asynchronously.
Declaration
virtual long ReadFrom(Stream source)
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream. |
Returns
Type | Description |
---|---|
Int64 |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory has been released. |
ReadFromAsync(Stream, CancellationToken)
Copies bytes from the given stream to the memory location identified by this object asynchronously.
Declaration
virtual ValueTask<long> ReadFromAsync(Stream source, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream. |
CancellationToken | token | The token that can be used to cancel operation. |
Returns
Type | Description |
---|---|
ValueTask<Int64> |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory has been released. |
OperationCanceledException | The operation has been canceled. |
WriteTo(Pointer<Byte>)
Copies elements from the current memory location to the specified memory location.
Declaration
virtual void WriteTo(Pointer<byte> destination)
Parameters
Type | Name | Description |
---|---|---|
Pointer<Byte> | destination | The target memory location. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory has been released. |
WriteTo(Stream)
Copies bytes from the memory location to the stream.
Declaration
virtual void WriteTo(Stream destination)
Parameters
Type | Name | Description |
---|---|---|
Stream | destination | The destination stream. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory has been released. |
WriteToAsync(Stream, CancellationToken)
Copies bytes from the memory location to the stream asynchronously.
Declaration
virtual ValueTask WriteToAsync(Stream destination, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | destination | The destination stream. |
CancellationToken | token | The token that can be used to cancel operation. |
Returns
Type | Description |
---|---|
ValueTask | The task instance representing asynchronous state of the copying process. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The underlying unmanaged memory has been released. |
OperationCanceledException | The operation has been canceled. |