Documentation
¶
Overview ¶
Package msgpack implements functions for the encoding and decoding values in msgpack format.
Package msgpack implements functions for the encoding and decoding values in msgpack format.
Package msgpack implements functions for the encoding and decoding values in msgpack format.
Package msgpack implements functions for the encoding and decoding values in msgpack format.
Package msgpack implements functions for the encoding and decoding values in msgpack format.
Package msgpack implements functions for the encoding and decoding values in msgpack format.
Package msgpack implements functions for the encoding and decoding values in msgpack format.
Index ¶
- Variables
- func IsArray(format Format) bool
- func IsBin(format Format) bool
- func IsExt(format Format) bool
- func IsFixedArray(format Format) bool
- func IsFixedExt(format Format) bool
- func IsFixedMap(format Format) bool
- func IsFixedNum(format Format) bool
- func IsFixedString(format Format) bool
- func IsFloat(format Format) bool
- func IsInteger(format Format) bool
- func IsMap(format Format) bool
- func IsNegativeInteger(format Format) bool
- func IsPositiveInteger(format Format) bool
- func IsString(format Format) bool
- type CustomDecoder
- type CustomDecoderFunc
- type CustomEncoder
- type CustomEncoderFunc
- type Decoder
- func (d *Decoder) ArrayLen() (int, error)
- func (d *Decoder) Bool() (bool, error)
- func (d *Decoder) Bytes() ([]byte, error)
- func (d *Decoder) Ext() (interface{}, error)
- func (d *Decoder) ExtData() (Ext, []byte, error)
- func (d *Decoder) Float32() (float32, error)
- func (d *Decoder) Float64() (float64, error)
- func (d *Decoder) Format() (Format, error)
- func (d *Decoder) Int() (int, error)
- func (d *Decoder) Int16() (int16, error)
- func (d *Decoder) Int32() (int32, error)
- func (d *Decoder) Int64() (int64, error)
- func (d *Decoder) Int8() (int8, error)
- func (d *Decoder) Interface() (interface{}, error)
- func (d *Decoder) MapLen() (int, error)
- func (d *Decoder) Nil() error
- func (d *Decoder) PeekFormat() (Format, error)
- func (d *Decoder) RegisterExtDecoder(code Ext, fn ExtDecoderFn)
- func (d *Decoder) Reset(r Reader)
- func (d *Decoder) Skip() error
- func (d *Decoder) String() (string, error)
- func (d *Decoder) Time() (time.Time, error)
- func (d *Decoder) Uint() (uint, error)
- func (d *Decoder) Uint16() (uint16, error)
- func (d *Decoder) Uint32() (uint32, error)
- func (d *Decoder) Uint64() (uint64, error)
- func (d *Decoder) Uint8() (uint8, error)
- type Encoder
- func (e *Encoder) ArrayLen(length int) error
- func (e *Encoder) Bool(v bool) error
- func (e *Encoder) Bytes(v []byte) error
- func (e *Encoder) ExtData(code Ext, data []byte) error
- func (e *Encoder) Float32(v float32) error
- func (e *Encoder) Float64(v float64) error
- func (e *Encoder) Int(v int) error
- func (e *Encoder) Int16(v int16) error
- func (e *Encoder) Int32(v int32) error
- func (e *Encoder) Int64(v int64) error
- func (e *Encoder) Int8(v int8) error
- func (e *Encoder) Interface(value interface{}) error
- func (e *Encoder) MapLen(length int) error
- func (e *Encoder) Nil() error
- func (e *Encoder) Reset(w Writer)
- func (e *Encoder) String(v string) error
- func (e *Encoder) Time(time time.Time) error
- func (e *Encoder) Uint(v uint) error
- func (e *Encoder) Uint16(v uint16) error
- func (e *Encoder) Uint32(v uint32) error
- func (e *Encoder) Uint64(v uint64) error
- func (e *Encoder) Uint8(v uint8) error
- type Ext
- type ExtDecoderFn
- type Format
- type FormatError
- type Reader
- type UnexpectedExtension
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( ErrNanosecondsTooLarge = errors.New("nanoseconds too large") ErrNegativeLength = errors.New("length cannot be negative") ErrLengthTooLong = errors.New("struct length is too long") ErrOverflow = errors.New("value overflows int range") ErrUnexpectedFormat = errors.New("unexpected format") ErrUnsupportedMapKey = errors.New("decoded map key is unsupported") ErrUnsupportedType = errors.New("value has unsupported type") )
Package level errors.
Functions ¶
func IsFixedArray ¶ added in v1.1.0
IsFixedArray checks if format is a fixed length array.
func IsFixedExt ¶ added in v1.1.0
IsFixedExt checks if format is a fixed length extension.
func IsFixedMap ¶ added in v1.1.0
IsFixedMap checks if format is a fixed length map.
func IsFixedNum ¶ added in v1.1.0
IsFixedNum checks if format is a fixed number value.
func IsFixedString ¶ added in v1.1.0
IsFixedString checks if format is a fixed length string.
func IsNegativeInteger ¶ added in v1.2.0
IsNegativeInteger checks if format represents negative integer.
func IsPositiveInteger ¶ added in v1.2.0
IsPositiveInteger checks if format represents positive integer.
Types ¶
type CustomDecoder ¶
CustomDecoder declares method which indicates structure is support custom decoding from msgpack.
type CustomDecoderFunc ¶ added in v1.3.0
CustomDecoderFunc defines a function implemented CustomDecoder interface.
func (CustomDecoderFunc) DecodeMsgpack ¶ added in v1.3.0
func (fn CustomDecoderFunc) DecodeMsgpack(dec *Decoder) error
DecodeMsgpack implements CustomDecoder interface.
type CustomEncoder ¶
CustomEncoder declares method which indicates structure is support custom encoding from msgpack.
type CustomEncoderFunc ¶ added in v1.3.0
CustomEncoderFunc defines a function implemented CustomEncoder interface.
func (CustomEncoderFunc) EncodeMsgpack ¶ added in v1.3.0
func (fn CustomEncoderFunc) EncodeMsgpack(enc *Encoder) error
EncodeMsgpack implements CustomEncoder interface.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder allows to decode msgpack stream from Reader.
func NewDecoder ¶
NewDecoder returns a new instance of msgpack Decoder.
func (*Decoder) PeekFormat ¶
PeekFormat returns current msgpack format code but next call Format will return the same format.
func (*Decoder) RegisterExtDecoder ¶ added in v1.4.0
func (d *Decoder) RegisterExtDecoder(code Ext, fn ExtDecoderFn)
RegisterExtDecoder registers a custom decoder for extensions with specified code.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder allows to encode and write msgpack values to Writer.
func (*Encoder) Interface ¶ added in v1.2.0
Interface encodes any scalar value or structure has implemented CustomEncoder as msgpack value.
type Ext ¶
type Ext int8
Ext represents codes of msgpack extension.
const ( // ExtTimestamp is a code of Timestamp extension. ExtTimestamp Ext = -1 )
type ExtDecoderFn ¶ added in v1.4.0
ExtDecoderFn defines an interface for custom extension decoders.
type Format ¶
type Format uint8
Format represents format codes of msgpack types.
const ( FormatPositiveFixIntMax Format = 0x7f // PositiveFixIntMax FormatNegativeFixIntMin Format = 0xe0 // NegativeFixIntMin FormatFixMapMin Format = 0x80 // FixMapMin FormatFixMapMax Format = 0x8f // FixMapMax FormatFixArrayMin Format = 0x90 // FixArrayMin FormatFixArrayMax Format = 0x9f // FixArrayMax FormatFixStringMin Format = 0xa0 // FixStringMin FormatFixStringMax Format = 0xbf // FixStringMax )
Codes for range formats.
const ( FormatNil Format = 0xc0 + iota // Nil FormatFalse // False FormatTrue // True FormatBin8 // Bin8 FormatBin16 // Bin16 FormatBin32 // Bin32 FormatExt8 // Ext8 FormatExt16 // Ext16 FormatExt32 // Ext32 FormatFloat32 // Float32 FormatFloat64 // Float64 FormatUint8 // Uint8 FormatUint16 // Uint16 FormatUint32 // Uint32 FormatUint64 // Uint64 FormatInt8 // Int8 FormatInt16 // Int16 FormatInt32 // Int32 FormatInt64 // Int64 FormatFixExt1 // FixExt1 FormatFixExt2 // FixExt2 FormatFixExt4 // FixExt4 FormatFixExt8 // FixExt8 FormatFixExt16 // FixExt16 FormatString8 // String8 FormatString16 // String16 FormatString32 // String32 FormatArray16 // Array16 FormatArray32 // Array32 FormatMap16 // Map16 FormatMap32 // Map32 )
Static format codes.
const ( // FormatUnknown is default format code witch means a code is unknown. FormatUnknown Format = 0 // Unknown )
type FormatError ¶ added in v1.2.0
FormatError is a wrapper for discard format errors.
func NewFormatError ¶ added in v1.2.0
func NewFormatError(format Format, err error) *FormatError
NewFormatError returns a new instance of FormatError.
func (FormatError) Cause ¶ added in v1.2.0
func (e FormatError) Cause() error
Cause returns origin error.
func (FormatError) Error ¶ added in v1.2.0
func (e FormatError) Error() string
Error implements error interface.
type Reader ¶
type Reader interface { io.ByteScanner io.Reader }
Reader describes interface required by Decoder.
type UnexpectedExtension ¶
type UnexpectedExtension struct {
Extension Ext
}
UnexpectedExtension is an error for unexpected extension while decoding.
func NewUnexpectedExtension ¶
func NewUnexpectedExtension(extension Ext) *UnexpectedExtension
NewUnexpectedExtension creates a new instance of UnexpectedExtension.
func (UnexpectedExtension) Error ¶
func (u UnexpectedExtension) Error() string
Error implements error interface.