Documentation
¶
Index ¶
- func DecodeWrapperMap(dec *msgpack.Decoder) (string, error)
- func EncodeMapStart(enc *msgpack.Encoder, key string) error
- type MapItems
- type MsgpackEncFunc
- func EncoderFuncArray[T any](key string, items []T, itemEnc func(T) error) MsgpackEncFunc
- func EncoderFuncBool(key string, value bool) MsgpackEncFunc
- func EncoderFuncInt(key string, value int) MsgpackEncFunc
- func EncoderFuncMarshal(key string, wf MsgpackEncFunc) MsgpackEncFunc
- func EncoderFuncString(key, value string) MsgpackEncFunc
- func EncoderFuncUInt(key string, value uint) MsgpackEncFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeWrapperMap ¶
DecodeWrapperMap reads the "single item map" whose key is string - the key name is returned and decoder is ready to read the value. It is suitable to read what EncodeMapStart produced.
Types ¶
type MapItems ¶
type MapItems []MsgpackEncFunc
func (*MapItems) AddOptionalEncoder ¶
func (ef *MapItems) AddOptionalEncoder(add bool, encFunc MsgpackEncFunc)
AddOptionalEncoder adds the encoder function only if the add flag is true.
func (*MapItems) AddOptionalStr ¶
AddOptionalStr adds the key/value only if the value is non empty string.
func (*MapItems) AddOptionalUInt ¶
func (MapItems) EncodeMap ¶
EncodeMap encodes fixed size map using the enc - it writes the number of items and then calls each item to serialize the actual key - value pair.
The mapName argument is used to add context to the error messages (when encoding fails) and not used otherwise (ie does not appear in encoded map).
type MsgpackEncFunc ¶
func EncoderFuncArray ¶
func EncoderFuncArray[T any](key string, items []T, itemEnc func(T) error) MsgpackEncFunc
EncoderFuncArray writes "named array".
- key : the name of the array, ie it's the key whose value will be the array;
- items : slice of items to store as array values;
- itemEnc : function which encodes item, ie enc.EncodeString
Returns function which can be used with MapItems.
func EncoderFuncBool ¶
func EncoderFuncBool(key string, value bool) MsgpackEncFunc
func EncoderFuncInt ¶
func EncoderFuncInt(key string, value int) MsgpackEncFunc
func EncoderFuncMarshal ¶
func EncoderFuncMarshal(key string, wf MsgpackEncFunc) MsgpackEncFunc
Callback is the "standard marshaler" signature.
func EncoderFuncString ¶
func EncoderFuncString(key, value string) MsgpackEncFunc
EncoderFuncString returns function which encodes string key-value pair. Meant to be used with MapItems to store string value.
func EncoderFuncUInt ¶
func EncoderFuncUInt(key string, value uint) MsgpackEncFunc