Table of Contents

Class Codec<T>

Namespace
Shard.Codecs
Assembly
Shard.Codecs.dll

Executes the JSON, BSON, and validation programs for one value type.

public sealed class Codec<T>

Type Parameters

T
Inheritance
Codec<T>
Inherited Members

Remarks

Because a codec describes only a value, asset keys, component identities, schemas, registries, and lifecycle belong to their bindings.

Methods

DecodeBson(ReadOnlyMemory<byte>)

Decodes exactly one BSON root and validates the completed result.

public T DecodeBson(ReadOnlyMemory<byte> source)

Parameters

source ReadOnlyMemory<byte>

Returns

T

DecodeBson(ReadOnlyMemory<byte>, CodecContext)

Decodes exactly one BSON root with the supplied operation context and validates the completed result.

public T DecodeBson(ReadOnlyMemory<byte> source, CodecContext context)

Parameters

source ReadOnlyMemory<byte>
context CodecContext

Returns

T

DecodeJson(ReadOnlySpan<byte>)

Decodes exactly one UTF-8 JSON value and validates the completed result.

public T DecodeJson(ReadOnlySpan<byte> source)

Parameters

source ReadOnlySpan<byte>

Returns

T

DecodeJson(ReadOnlySpan<byte>, CodecContext)

Decodes exactly one UTF-8 JSON value with the supplied operation context and validates the completed result.

public T DecodeJson(ReadOnlySpan<byte> source, CodecContext context)

Parameters

source ReadOnlySpan<byte>
context CodecContext

Returns

T

EncodeBson(IBufferWriter<byte>, in T)

Encodes one BSON root without running validation implicitly.

public void EncodeBson(IBufferWriter<byte> destination, in T value)

Parameters

destination IBufferWriter<byte>
value T

EncodeBson(IBufferWriter<byte>, in T, CodecContext)

Encodes one BSON root with the supplied operation context without running validation implicitly.

public void EncodeBson(IBufferWriter<byte> destination, in T value, CodecContext context)

Parameters

destination IBufferWriter<byte>
value T
context CodecContext

Validate(in T)

Runs the codec's recursive validator as a complete operation and reports all collected failures.

public void Validate(in T value)

Parameters

value T

Validate(in T, CodecContext)

Runs the codec's recursive validator with the supplied operation context and reports all collected failures.

public void Validate(in T value, CodecContext context)

Parameters

value T
context CodecContext