Documentation
¶
Overview ¶
Package codec provides a generic, type-safe codec abstraction used for encoding and decoding values in the cmd-stream-go ecosystem.
Index ¶
- func NewFailedToMarshalByteSlice(err error) error
- func NewFailedToMarshalDTM(err error) error
- func NewFailedToMarshalValue(value any, cause error) error
- func NewFailedToUnmarshalByteSlice(err error) error
- func NewFailedToUnmarshalDTM(err error) error
- func NewFailedToUnmarshalValue(err error) error
- func NewUnrecognizedDTM(dtm com.DTM) error
- func NewUnrecognizedType(t reflect.Type) error
- type Codec
- type DecodeValueFn
- type Serializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFailedToMarshalByteSlice ¶
NewFailedToMarshalByteSlice returns an error indicating that a byte slice could not be marshaled.
func NewFailedToMarshalDTM ¶
NewFailedToMarshalDTM returns an error indicating that the data type marker (DTM) could not be marshaled.
func NewFailedToMarshalValue ¶
NewFailedToMarshalValue returns an error indicating that value marshaling failed.
func NewFailedToUnmarshalByteSlice ¶
NewFailedToUnmarshalByteSlice returns an error indicating that a byte slice could not be unmarshaled.
func NewFailedToUnmarshalDTM ¶
NewFailedToUnmarshalDTM returns an error indicating that the data type marker (DTM) could not be unmarshaled.
func NewFailedToUnmarshalValue ¶
NewFailedToUnmarshalValue returns an error indicating that value unmarshaling failed.
func NewUnrecognizedDTM ¶
NewUnrecognizedDTM returns an error indicating that an unknown data type marker (DTM) was received.
func NewUnrecognizedType ¶
NewUnrecognizedType returns an error indicating that an unsupported type was encountered during encoding.
Types ¶
type Codec ¶
type Codec[T, V any] struct { // contains filtered or unexported fields }
Codec represents a generic type-safe codec for encoding and decoding values. T is the type used for encoding, V is the type used for decoding.
func NewCodec ¶
func NewCodec[T, V any](types1 []reflect.Type, types2 []reflect.Type, ser Serializer[T, V], ) (codec Codec[T, V])
NewCodec constructs a Codec with default value decoder logic.
Parameters:
- types1 lists the Go types that can be encoded.
- types2 lists the Go types that can be decoded.
- ser is the serializer used for encoding/decoding values.
func NewCodecWithDecoder ¶
func NewCodecWithDecoder[T, V any](types1 []reflect.Type, types2 []reflect.Type, ser Serializer[T, V], decodeValueFn DecodeValueFn[T, V], ) (codec Codec[T, V])
NewCodecWithDecoder constructs a Codec using a custom value decoder function.
decodeValueFn allows overriding the default decoding behavior.