Interface ISerializable<TSelf>
Represents an object that supports serialization and deserialization.
Inherited Members
Namespace: DotNext.Runtime.Serialization
Assembly: DotNext.IO.dll
Syntax
public interface ISerializable<TSelf> : IDataTransferObject where TSelf : ISerializable<TSelf>
Type Parameters
Name | Description |
---|---|
TSelf | The implementing type. |
Methods
| Edit this page View SourceReadFromAsync(PipeReader, CancellationToken)
Deserializes the object from the pipe.
Declaration
public static ValueTask<TSelf> ReadFromAsync(PipeReader reader, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
PipeReader | reader | The pipe reader. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<TSelf> | Deserialized object. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ReadFromAsync(Stream, int, CancellationToken)
Deserializes the object from the stream.
Declaration
public static ValueTask<TSelf> ReadFromAsync(Stream input, int bufferSize = 128, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
Stream | input | The stream containing serialized data. |
int | bufferSize | The size of the buffer to be used for reading from the stream. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<TSelf> | Deserialized object. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ReadFromAsync(Stream, Memory<byte>, CancellationToken)
Deserializes the object from the stream.
Declaration
public static ValueTask<TSelf> ReadFromAsync(Stream input, Memory<byte> buffer, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
Stream | input | The stream containing serialized data. |
Memory<byte> | buffer | The buffer to be used for reading from the stream. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<TSelf> | Deserialized object. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
ReadFromAsync<TReader>(TReader, CancellationToken)
Decodes the object of type TSelf
from its binary representation.
Declaration
public static abstract ValueTask<TSelf> ReadFromAsync<TReader>(TReader reader, CancellationToken token) where TReader : notnull, IAsyncBinaryReader
Parameters
Type | Name | Description |
---|---|---|
TReader | reader | The reader. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<TSelf> | The decoded object. |
Type Parameters
Name | Description |
---|---|
TReader | The type of the reader. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
TransformAsync<TInput>(TInput, CancellationToken)
Transforms one object into another object.
Declaration
public static ValueTask<TSelf> TransformAsync<TInput>(TInput input, CancellationToken token = default) where TInput : notnull, IDataTransferObject
Parameters
Type | Name | Description |
---|---|---|
TInput | input | The object to transform. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<TSelf> | Deserialized object. |
Type Parameters
Name | Description |
---|---|
TInput | The type of the object to transform. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |