Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Timestamp int8 = -1
Functions ¶
This section is empty.
Types ¶
type EncoderState ¶
type EncoderState struct {
// contains filtered or unexported fields
}
EncoderState contains data to correctly encode the current type.
func NewEncoderState ¶
func NewEncoderState() *EncoderState
func (*EncoderState) SetExternalTypeHandler ¶
func (e *EncoderState) SetExternalTypeHandler(typeInvolved interface{}, handler ExtUserHandler) error
SetExternalTypeHandler associate a specific data type with a custom encoding function provided by the user. Code is a number between 0 and 127 and indicate the correspondent MessagePack External type code. The handler function receives the value to encode as an empty interface, so it needs to do a type assertion and provide a byte array as result, along with an eventual error (error = nil if there were no errors).
func (*EncoderState) TypeWrapper ¶
func (e *EncoderState) TypeWrapper(value reflect.Value) utils.MessagePackTypeEncoder
TypeWrapper convert a primitive type into its messagepack correspondent type using reflection.
type EncodingStruct ¶
EncodingStruct is the internal representation of a Go struct which is used to do the encoding to MessagePack.
func NewEncodingStruct ¶
func NewEncodingStruct(s types.Struct, e *EncoderState) EncodingStruct
func (EncodingStruct) Len ¶
func (e EncodingStruct) Len() int
Len returns the length of the MessagePack encoded struct. It returns 0 if the struct has already been written.
func (EncodingStruct) WriteTo ¶
func (e EncodingStruct) WriteTo(w io.Writer) (int64, error)
WriteTo writes the encoding of the struct value to io.Writer. It implements io.WriterTo interface. It returns the number of written bytes and an optional error. It doesn't write anything if it has already been written, to prevent cyclic reference between multiple structs.
type ExtUserHandler ¶
ExtUserHandler is a function that handle a custom encode defined by the user, and serializes to a MessagePack External.