Documentation ¶
Index ¶
- Constants
- func IsArrayFamily(c Code) bool
- func IsBinFamily(c Code) bool
- func IsExtFamily(c Code) bool
- func IsFixNumFamily(c Code) bool
- func IsMapFamily(c Code) bool
- func IsNegativeFixNum(c Code) bool
- func IsPositiveFixNum(c Code) bool
- func IsStrFamily(c Code) bool
- func Marshal(v interface{}) ([]byte, error)
- func RegisterExt(typ int, v interface{}) error
- func Unmarshal(data []byte, v interface{}) error
- func WriteArrayHeader(dst io.Writer, c int) error
- func WriteMapHeader(dst io.Writer, c int) error
- type ArrayBuilder
- type Code
- type DecodeMsgpacker
- type Decoder
- func (d *Decoder) Decode(v interface{}) error
- func (d *Decoder) DecodeArray(v interface{}) error
- func (d *Decoder) DecodeArrayLength(l *int) error
- func (d *Decoder) DecodeBool(b *bool) error
- func (d *Decoder) DecodeBytes(v *[]byte) error
- func (d *Decoder) DecodeExt(v DecodeMsgpacker) error
- func (d *Decoder) DecodeExtLength(l *int) error
- func (d *Decoder) DecodeExtType(v *reflect.Type) error
- func (d *Decoder) DecodeFloat32(v *float32) error
- func (d *Decoder) DecodeFloat64(v *float64) error
- func (d *Decoder) DecodeInt(v *int) error
- func (d *Decoder) DecodeInt16(v *int16) error
- func (d *Decoder) DecodeInt32(v *int32) error
- func (d *Decoder) DecodeInt64(v *int64) error
- func (d *Decoder) DecodeInt8(v *int8) error
- func (d *Decoder) DecodeMap(v *map[string]interface{}) error
- func (d *Decoder) DecodeMapLength(l *int) error
- func (d *Decoder) DecodeNil(v *interface{}) error
- func (d *Decoder) DecodeString(s *string) error
- func (d *Decoder) DecodeStruct(v interface{}) error
- func (d *Decoder) DecodeTime(v *time.Time) error
- func (d *Decoder) DecodeUint(v *uint) error
- func (d *Decoder) DecodeUint16(v *uint16) error
- func (d *Decoder) DecodeUint32(v *uint32) error
- func (d *Decoder) DecodeUint64(v *uint64) error
- func (d *Decoder) DecodeUint8(v *uint8) error
- func (d *Decoder) PeekCode() (Code, error)
- func (d *Decoder) ReadCode() (Code, error)
- func (d *Decoder) Reader() Reader
- type EncodeMsgpacker
- type Encoder
- func (e *Encoder) Encode(v interface{}) error
- func (e *Encoder) EncodeArray(v interface{}) error
- func (e *Encoder) EncodeArrayHeader(l int) error
- func (e *Encoder) EncodeBool(b bool) error
- func (e *Encoder) EncodeBytes(b []byte) error
- func (e *Encoder) EncodeExt(v EncodeMsgpacker) error
- func (e *Encoder) EncodeExtHeader(l int) error
- func (e *Encoder) EncodeExtType(v EncodeMsgpacker) error
- func (e *Encoder) EncodeFloat32(f float32) error
- func (e *Encoder) EncodeFloat64(f float64) error
- func (e *Encoder) EncodeInt(v int) error
- func (e *Encoder) EncodeInt16(v int16) error
- func (e *Encoder) EncodeInt32(v int32) error
- func (e *Encoder) EncodeInt64(v int64) error
- func (e *Encoder) EncodeInt8(v int8) error
- func (e *Encoder) EncodeMap(v interface{}) error
- func (e *Encoder) EncodeNegativeFixNum(i int8) error
- func (e *Encoder) EncodeNil() error
- func (e *Encoder) EncodePositiveFixNum(i uint8) error
- func (e *Encoder) EncodeString(s string) error
- func (e *Encoder) EncodeStruct(v interface{}) error
- func (e *Encoder) EncodeTime(t time.Time) error
- func (e *Encoder) EncodeUint(v uint) error
- func (e *Encoder) EncodeUint16(v uint16) error
- func (e *Encoder) EncodeUint32(v uint32) error
- func (e *Encoder) EncodeUint64(v uint64) error
- func (e *Encoder) EncodeUint8(v uint8) error
- func (e *Encoder) Writer() Writer
- type InvalidDecodeError
- type MapBuilder
- type Reader
- type Writer
Constants ¶
const MaxPositiveFixNum = byte(0x7f)
const MinNegativeFixNum = byte(0xe0)
Variables ¶
This section is empty.
Functions ¶
func IsArrayFamily ¶
IsArrayFamily returns true if the given code is equivalent to one of the `array` family in msgpack
func IsBinFamily ¶
IsBinFamily returns true if the given code is equivalent to one of the `bin` family in msgpack
func IsExtFamily ¶
IsExtFamily returns true if the given code is equivalent to one of the `ext` family in msgpack
func IsFixNumFamily ¶
IsFixNumFamily returns true if the given code is equivalent to one of the fixed num family
func IsMapFamily ¶
IsMapFamily returns true if the given code is equivalent to one of the `map` family in msgpack
func IsNegativeFixNum ¶
func IsPositiveFixNum ¶
func IsStrFamily ¶
IsStrFamily returns true if the given code is equivalent to one of the `str` family in msgpack
func RegisterExt ¶
Types ¶
type ArrayBuilder ¶
type ArrayBuilder interface { Add(interface{}) Bytes() ([]byte, error) Count() int Encode(io.Writer) error Reset() }
ArrayBuilder is used to build a msgpack array
func NewArrayBuilder ¶
func NewArrayBuilder() ArrayBuilder
type Code ¶
type Code byte
Code represents the first by in a msgpack element. It tell us the data layout that follows it
const ( InvalidCode Code = 0 FixMap0 Code = 0x80 FixMap1 Code = 0x81 FixMap2 Code = 0x82 FixMap3 Code = 0x83 FixMap4 Code = 0x84 FixMap5 Code = 0x85 FixMap6 Code = 0x86 FixMap7 Code = 0x87 FixMap8 Code = 0x88 FixMap9 Code = 0x89 FixMap10 Code = 0x8a FixMap11 Code = 0x8b FixMap12 Code = 0x8c FixMap13 Code = 0x8d FixMap14 Code = 0x8e FixMap15 Code = 0x8f FixArray0 Code = 0x90 FixArray1 Code = 0x91 FixArray2 Code = 0x92 FixArray3 Code = 0x93 FixArray4 Code = 0x94 FixArray5 Code = 0x95 FixArray6 Code = 0x96 FixArray7 Code = 0x97 FixArray8 Code = 0x98 FixArray9 Code = 0x99 FixArray10 Code = 0x9a FixArray11 Code = 0x9b FixArray12 Code = 0x9c FixArray13 Code = 0x9d FixArray14 Code = 0x9e FixArray15 Code = 0x9f NegFixedNumLow Code = 0xe0 FixStr0 Code = 0xa0 FixStr1 Code = 0xa1 FixStr2 Code = 0xa2 FixStr3 Code = 0xa3 FixStr4 Code = 0xa4 FixStr5 Code = 0xa5 FixStr6 Code = 0xa6 FixStr7 Code = 0xa7 FixStr8 Code = 0xa8 FixStr9 Code = 0xa9 FixStr10 Code = 0xaa FixStr11 Code = 0xab FixStr12 Code = 0xac FixStr13 Code = 0xad FixStr14 Code = 0xae FixStr15 Code = 0xaf FixStr16 Code = 0xb0 FixStr17 Code = 0xb1 FixStr18 Code = 0xb2 FixStr19 Code = 0xb3 FixStr20 Code = 0xb4 FixStr21 Code = 0xb5 FixStr22 Code = 0xb6 FixStr23 Code = 0xb7 FixStr24 Code = 0xb8 FixStr25 Code = 0xb9 FixStr26 Code = 0xba FixStr27 Code = 0xbb FixStr28 Code = 0xbc FixStr29 Code = 0xbd FixStr30 Code = 0xbe FixStr31 Code = 0xbf Nil Code = 0xc0 False Code = 0xc2 True Code = 0xc3 Bin8 Code = 0xc4 Bin16 Code = 0xc5 Bin32 Code = 0xc6 Ext8 Code = 0xc7 Ext16 Code = 0xc8 Ext32 Code = 0xc9 Float Code = 0xca Double Code = 0xcb Uint8 Code = 0xcc Uint16 Code = 0xcd Uint32 Code = 0xce Uint64 Code = 0xcf Int8 Code = 0xd0 Int16 Code = 0xd1 Int32 Code = 0xd2 Int64 Code = 0xd3 FixExt1 Code = 0xd4 FixExt2 Code = 0xd5 FixExt4 Code = 0xd6 FixExt8 Code = 0xd7 FixExt16 Code = 0xd8 Str8 Code = 0xd9 Str16 Code = 0xda Str32 Code = 0xdb Array16 Code = 0xdc Array32 Code = 0xdd Map16 Code = 0xde Map32 Code = 0xdf FixedArrayMask Code = 0xf )
type DecodeMsgpacker ¶
DecodeMsgpacker is an interface for those objects that provide their own deserialization. The objects are responsible for handling the code, payload length (if applicable), and payload (if applicable)
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Encoder reads serialized data from a source pointed to by an io.Reader
func NewDecoder ¶
func (*Decoder) Decode ¶
Decode takes a pointer to a variable, and populates it with the value that was unmarshaled from the stream.
If the variable is a non-pointer or nil, an error is returned.
func (*Decoder) DecodeArray ¶
func (*Decoder) DecodeArrayLength ¶
func (*Decoder) DecodeBool ¶
func (*Decoder) DecodeBytes ¶
func (*Decoder) DecodeExt ¶
func (d *Decoder) DecodeExt(v DecodeMsgpacker) error
func (*Decoder) DecodeExtLength ¶
func (*Decoder) DecodeFloat32 ¶
func (*Decoder) DecodeFloat64 ¶
func (*Decoder) DecodeInt16 ¶
func (*Decoder) DecodeInt32 ¶
func (*Decoder) DecodeInt64 ¶
func (*Decoder) DecodeInt8 ¶
func (*Decoder) DecodeMapLength ¶
func (*Decoder) DecodeString ¶
func (*Decoder) DecodeStruct ¶
func (*Decoder) DecodeUint ¶
func (*Decoder) DecodeUint16 ¶
func (*Decoder) DecodeUint32 ¶
func (*Decoder) DecodeUint64 ¶
func (*Decoder) DecodeUint8 ¶
type EncodeMsgpacker ¶
EncodeMsgpacker is an interface for those objects that provide their own serialization. The objects are responsible for providing the complete msgpack payload, including the code, payload length (if applicable), and payload (if applicable)
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder writes serialized data to a destination pointed to by an io.Writer
func NewEncoder ¶
NewEncoder creates a new Encoder that writes serialized forms to the specified io.Writer
Note that Encoders are NEVER meant to be shared concurrently between goroutines. You DO NOT write serialized data concurrently to the same destination.
func (*Encoder) EncodeArray ¶
func (*Encoder) EncodeArrayHeader ¶
func (*Encoder) EncodeBool ¶
func (*Encoder) EncodeBytes ¶
func (*Encoder) EncodeExt ¶
func (e *Encoder) EncodeExt(v EncodeMsgpacker) error
func (*Encoder) EncodeExtHeader ¶
func (*Encoder) EncodeExtType ¶
func (e *Encoder) EncodeExtType(v EncodeMsgpacker) error
func (*Encoder) EncodeFloat32 ¶
func (*Encoder) EncodeFloat64 ¶
func (*Encoder) EncodeInt16 ¶
func (*Encoder) EncodeInt32 ¶
func (*Encoder) EncodeInt64 ¶
func (*Encoder) EncodeInt8 ¶
func (*Encoder) EncodeNegativeFixNum ¶
func (*Encoder) EncodePositiveFixNum ¶
func (*Encoder) EncodeString ¶
func (*Encoder) EncodeStruct ¶
EncodeStruct encodes a struct value as a map object.
func (*Encoder) EncodeTime ¶
EncodeTime encodes time.Time as a sequence of two integers
func (*Encoder) EncodeUint ¶
func (*Encoder) EncodeUint16 ¶
func (*Encoder) EncodeUint32 ¶
func (*Encoder) EncodeUint64 ¶
func (*Encoder) EncodeUint8 ¶
type InvalidDecodeError ¶
func (*InvalidDecodeError) Error ¶
func (e *InvalidDecodeError) Error() string
type MapBuilder ¶
type MapBuilder interface { Add(string, interface{}) Bytes() ([]byte, error) Count() int Encode(io.Writer) error Reset() }
MapBuilder is used to build a msgpack map
func NewMapBuilder ¶
func NewMapBuilder() MapBuilder
type Reader ¶
type Reader interface { io.Reader ReadByte() (byte, error) ReadUint8() (uint8, error) ReadUint16() (uint16, error) ReadUint32() (uint32, error) ReadUint64() (uint64, error) ReadByteUint8() (byte, uint8, error) ReadByteUint16() (byte, uint16, error) ReadByteUint32() (byte, uint32, error) ReadByteUint64() (byte, uint64, error) }
Reader handles low-level reading from an io.Reader. Note that Readers are NEVER meant to be shared concurrently between goroutines. You DO NOT read data concurrently from the same serialized source.
type Writer ¶
type Writer interface { io.Writer WriteByte(byte) error WriteByteUint8(byte, uint8) error WriteByteUint16(byte, uint16) error WriteByteUint32(byte, uint32) error WriteByteUint64(byte, uint64) error WriteString(string) (int, error) WriteUint8(uint8) error WriteUint16(uint16) error WriteUint32(uint32) error WriteUint64(uint64) error }
Writer handles low-level writing to an io.Writer. Note that Writers are NEVER meant to be shared concurrently between goroutines. You DO NOT write serialized data concurrently to the same destination.