Documentation ¶
Overview ¶
Package serdes provides different serialization and deserialization implementations using the serde.Serde interface found in the core module.
Index ¶
- func NewJSON[T any](factory func() T) serde.Fused[T, []byte]
- func NewJSONDeserializer[T any](factory func() T) serde.DeserializerFunc[T, []byte]
- func NewJSONSerializer[T any]() serde.SerializerFunc[T, []byte]
- func NewProto[T proto.Message](factory func() T) serde.Fused[T, []byte]
- func NewProtoDeserializer[T proto.Message](factory func() T) serde.DeserializerFunc[T, []byte]
- func NewProtoJSON[T proto.Message](factory func() T) serde.Fused[T, []byte]
- func NewProtoJSONDeserializer[T proto.Message](factory func() T) serde.DeserializerFunc[T, []byte]
- func NewProtoJSONSerializer[T proto.Message]() serde.SerializerFunc[T, []byte]
- func NewProtoSerializer[T proto.Message]() serde.SerializerFunc[T, []byte]
- type Chained
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewJSON ¶
NewJSON returns a new serde instance where some data (`T`) gets serialized to and deserialized from JSON as byte-array.
func NewJSONDeserializer ¶
func NewJSONDeserializer[T any](factory func() T) serde.DeserializerFunc[T, []byte]
NewJSONDeserializer returns a deserializer function where a byte-array is deserialized into the specified data type.
A data factory function is required for creating new instances of the type (especially if pointer semantics is used).
func NewJSONSerializer ¶
func NewJSONSerializer[T any]() serde.SerializerFunc[T, []byte]
NewJSONSerializer returns a serializer function where the input data (Src) gets serialized to JSON byte-array data.
func NewProto ¶
NewProto returns a new serde instance where some data (`T`) gets serialized to and deserialized from a Protobuf byte-array.
func NewProtoDeserializer ¶
func NewProtoDeserializer[T proto.Message](factory func() T) serde.DeserializerFunc[T, []byte]
NewProtoDeserializer returns a deserializer function where a byte-array is deserialized into a destination data type (T) using Protobuf.
A data factory function is required for creating new instances of type `T` (especially if pointer semantics is used).
func NewProtoJSON ¶
NewProtoJSON returns a new serde instance where some data (`T`) gets serialized to and deserialized from Protobuf JSON.
func NewProtoJSONDeserializer ¶
func NewProtoJSONDeserializer[T proto.Message](factory func() T) serde.DeserializerFunc[T, []byte]
NewProtoJSONDeserializer returns a deserializer function where a byte-array is deserialized into a destination model type (T) using Protobuf JSON.
A data factory function is required for creating new instances of type `T` (especially if pointer semantics is used).
func NewProtoJSONSerializer ¶
func NewProtoJSONSerializer[T proto.Message]() serde.SerializerFunc[T, []byte]
NewProtoJSONSerializer returns a serializer function where the input data (T) gets serialized to Protobuf JSON byte-array data.
func NewProtoSerializer ¶
func NewProtoSerializer[T proto.Message]() serde.SerializerFunc[T, []byte]
NewProtoSerializer returns a serializer function where the input data (T) gets serialized to Protobuf byte-array.
Types ¶
type Chained ¶
Chained is a serde type that allows to chain two separate serdes, to map from an Src to a Dst type, using a common supporting type in the middle (Mid).
func Chain ¶
func Chain[Src any, Mid any, Dst any]( first serde.Serde[Src, Mid], second serde.Serde[Mid, Dst], ) Chained[Src, Mid, Dst]
Chain chains together two serdes to build a new serde instance to map from Src to Dst types.
func (Chained[Src, Mid, Dst]) Deserialize ¶
Deserialize implements the serde.Deserializer interface.