Show / Hide Table of Contents

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 Source

Size

Gets size of the object, in bytes.

Declaration
public static abstract int Size { get; }
Property Value
Type Description
int

Methods

| Edit this page View Source

Format(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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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

true if the value converted successfully; otherwise, false.

| Edit this page View Source

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

true if the parsing done successfully; otherwise, false.

  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾