Class Codec<T>
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
sourceReadOnlyMemory<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
sourceReadOnlyMemory<byte>contextCodecContext
Returns
- T
DecodeJson(ReadOnlySpan<byte>)
Decodes exactly one UTF-8 JSON value and validates the completed result.
public T DecodeJson(ReadOnlySpan<byte> source)
Parameters
sourceReadOnlySpan<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
sourceReadOnlySpan<byte>contextCodecContext
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
destinationIBufferWriter<byte>valueT
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
destinationIBufferWriter<byte>valueTcontextCodecContext
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
valueT
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
valueTcontextCodecContext