Table of Contents

Interface ICodec

Namespace
Virtufin.Worker.DevKit.Codecs
Assembly
Virtufin.Worker.DevKit.dll

Payload ⇄ CloudEvent data, selected by datacontenttype and payload type.

Decode<T>(CloudEvent) reads the event's datacontenttype (absent: application/json, the CloudEvents default) and the requested payload type. Encode<T>(T, string) is given both: a payload type may have more than one wire form (JSON for state, FlatBuffers for the event), so the caller names the format and the codec never guesses.

Every failure is a CodecException: no NullReferenceException, InvalidCastException, KeyNotFoundException or JsonException escapes. The encoder's own datacontenttype is asserted against the requested one.

public interface ICodec

Methods

Decode<T>(CloudEvent)

Decode the event as T.

T Decode<T>(CloudEvent cloudEvent)

Parameters

cloudEvent CloudEvent

Returns

T

Type Parameters

T

Exceptions

CodecException

No codec, a failed decoder, or a payload of another type.

Encode<T>(T, string)

Encode payload as contentType.

CloudEvent Encode<T>(T payload, string contentType)

Parameters

payload T

The value; its static type selects the encoder.

contentType string

The wire format, e.g. application/json.

Returns

CloudEvent

Type Parameters

T

Exceptions

CodecException

No codec, a failed or mislabelled encoder, or a null payload.