Interface IBinaryFormattable<TSelf>
Represents an object that can be converted to and restored from the binary representation.
Namespace: DotNext.Buffers.Binary
Assembly: DotNext.dll
Syntax
public interface IBinaryFormattable<out TSelf> where TSelf : IBinaryFormattable<out TSelf>
Type Parameters
| Name | Description |
|---|---|
| TSelf | The implementing type. |
Properties
| Edit this page View SourceSize
Gets size of the object, in bytes.
Declaration
public static abstract int Size { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceFormat(Span<byte>)
Formats object as a sequence of bytes.
Declaration
void Format(Span<byte> destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<byte> | destination | The output buffer. |
Format(TSelf, MemoryAllocator<byte>?)
Formats object as a sequence of bytes.
Declaration
public static MemoryOwner<byte> Format(TSelf value, MemoryAllocator<byte>? allocator = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TSelf | value | The value to convert. |
| MemoryAllocator<byte> | allocator | The memory allocator. |
Returns
| Type | Description |
|---|---|
| MemoryOwner<byte> | The buffer containing formatted value. |
Parse(in ReadOnlySequence<byte>)
Restores the object from its binary representation.
Declaration
public static TSelf Parse(in ReadOnlySequence<byte> source)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySequence<byte> | source | The input buffer. |
Returns
| Type | Description |
|---|---|
| TSelf | The restored object. |
Parse(ReadOnlySpan<byte>)
Restores the object from its binary representation.
Declaration
public static abstract TSelf Parse(ReadOnlySpan<byte> source)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | source | The input buffer. |
Returns
| Type | Description |
|---|---|
| TSelf | The restored object. |
TryFormat(TSelf, Span<byte>)
Attempts to format object as a sequence of bytes.
Declaration
public static bool TryFormat(TSelf value, Span<byte> destination)
Parameters
| Type | Name | Description |
|---|---|---|
| TSelf | value | The value to convert. |
| Span<byte> | destination | The output buffer. |
Returns
| Type | Description |
|---|---|
| bool |
TryParse(ReadOnlySpan<byte>, out TSelf?)
Attempts to restore the object from its binary representation.
Declaration
public static bool TryParse(ReadOnlySpan<byte> source, out TSelf? result)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | source | The input buffer. |
| TSelf | result | The restored object. |
Returns
| Type | Description |
|---|---|
| bool |