msgp

package
v1.1.60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 5 Imported by: 59

Documentation

Overview

This package is the support library for the msgp code generator (http://github.com/algorand/msgp).

This package defines the utilites used by the msgp code generator for encoding and decoding MessagePack from []byte and io.Reader/io.Writer types. Much of this package is devoted to helping the msgp code generator implement the Marshaler/Unmarshaler and Encodable/Decodable interfaces.

This package defines four "families" of functions:

  • AppendXxxx() appends an object to a []byte in MessagePack encoding.
  • ReadXxxxBytes() reads an object from a []byte and returns the remaining bytes.
  • (*Writer).WriteXxxx() writes an object to the buffered *Writer type.
  • (*Reader).ReadXxxx() reads an object from a buffered *Reader type.

Once a type has satisfied the `Encodable` and `Decodable` interfaces, it can be written and read from arbitrary `io.Writer`s and `io.Reader`s using

msgp.Encode(io.Writer, msgp.Encodable)

and

msgp.Decode(io.Reader, msgp.Decodable)

There are also methods for converting MessagePack to JSON without an explicit de-serialization step.

For additional tips, tricks, and gotchas, please visit the wiki at http://github.com/tinylib/msgp

Index

Constants

View Source
const (
	// Complex64Extension is the extension number used for complex64
	Complex64Extension = 3

	// Complex128Extension is the extension number used for complex128
	Complex128Extension = 4

	// TimeExtension is the extension number used for time.Time
	TimeExtension = 5
)
View Source
const (
	Int64Size      = 9
	IntSize        = Int64Size
	UintSize       = Int64Size
	Int8Size       = 2
	Int16Size      = 3
	Int32Size      = 5
	Uint8Size      = 2
	ByteSize       = Uint8Size
	Uint16Size     = 3
	Uint32Size     = 5
	Uint64Size     = Int64Size
	Float64Size    = 9
	Float32Size    = 5
	Complex64Size  = 10
	Complex128Size = 18

	DurationSize = Int64Size
	TimeSize     = 15
	BoolSize     = 1
	NilSize      = 1

	MapHeaderSize   = 5
	ArrayHeaderSize = 5

	BytesPrefixSize     = 5
	StringPrefixSize    = 5
	ExtensionPrefixSize = 6
)

The sizes provided are the worst-case encoded sizes for each type. For variable- length types ([]byte, string), the total encoded size is the prefix size plus the length of the object.

View Source
const MaxInt = int((^uint(0)) >> 1)

MaxInt is the maximum int, which might be int32 or int64

Variables

View Source
var DefaultUnmarshalState = UnmarshalState{AllowableDepth: 10000}

DefaultUnmarshalState defines the default state.

View Source
var (
	// ErrShortBytes is returned when the
	// slice being decoded is too short to
	// contain the contents of the message
	ErrShortBytes error = errShort{}
)

Functions

func AppendArrayHeader

func AppendArrayHeader(b []byte, sz uint32) []byte

AppendArrayHeader appends an array header with the given size to the slice

func AppendBool

func AppendBool(b []byte, t bool) []byte

AppendBool appends a bool to the slice

func AppendByte

func AppendByte(b []byte, u byte) []byte

AppendByte is analogous to AppendUint8

func AppendBytes

func AppendBytes(b []byte, bts []byte) []byte

AppendBytes appends bytes to the slice as MessagePack 'bin' data

func AppendComplex128

func AppendComplex128(b []byte, c complex128) []byte

AppendComplex128 appends a complex128 to the slice as a MessagePack extension

func AppendComplex64

func AppendComplex64(b []byte, c complex64) []byte

AppendComplex64 appends a complex64 to the slice as a MessagePack extension

func AppendDuration added in v1.1.53

func AppendDuration(b []byte, d time.Duration) []byte

AppendDuration appends a time.Duration to the slice

func AppendExtension

func AppendExtension(b []byte, e Extension) ([]byte, error)

AppendExtension appends a MessagePack extension to the provided slice

func AppendFloat32

func AppendFloat32(b []byte, f float32) []byte

AppendFloat32 appends a float32 to the slice

func AppendFloat64

func AppendFloat64(b []byte, f float64) []byte

AppendFloat64 appends a float64 to the slice

func AppendInt16

func AppendInt16(b []byte, i int16) []byte

AppendInt16 appends an int16 to the slice

func AppendInt32

func AppendInt32(b []byte, i int32) []byte

AppendInt32 appends an int32 to the slice

func AppendInt64

func AppendInt64(b []byte, i int64) []byte

AppendInt64 appends an int64 to the slice

func AppendInt8

func AppendInt8(b []byte, i int8) []byte

AppendInt8 appends an int8 to the slice

func AppendMapHeader

func AppendMapHeader(b []byte, sz uint32) []byte

AppendMapHeader appends a map header with the given size to the slice

func AppendMapStrStr

func AppendMapStrStr(b []byte, m map[string]string) []byte

AppendMapStrStr appends a map[string]string to the slice as a MessagePack map with 'str'-type keys and values

func AppendNil

func AppendNil(b []byte) []byte

AppendNil appends a 'nil' byte to the slice

func AppendString

func AppendString(b []byte, s string) []byte

AppendString appends a string as a MessagePack 'str' to the slice

func AppendStringFromBytes

func AppendStringFromBytes(b []byte, str []byte) []byte

AppendStringFromBytes appends a []byte as a MessagePack 'str' to the slice 'b.'

func AppendTime

func AppendTime(b []byte, t time.Time) []byte

AppendTime appends a time.Time to the slice as a MessagePack extension

func AppendUint16

func AppendUint16(b []byte, u uint16) []byte

AppendUint16 appends a uint16 to the slice

func AppendUint32

func AppendUint32(b []byte, u uint32) []byte

AppendUint32 appends a uint32 to the slice

func AppendUint64

func AppendUint64(b []byte, u uint64) []byte

AppendUint64 appends a uint64 to the slice

func AppendUint8

func AppendUint8(b []byte, u uint8) []byte

AppendUint8 appends a uint8 to the slice

func Cause

func Cause(e error) error

Cause returns the underlying cause of an error that has been wrapped with additional context.

func ErrOverflow added in v1.1.16

func ErrOverflow(l uint64, bound uint64) error

func IsNil

func IsNil(b []byte) bool

IsNil returns true if len(b)>0 and the leading byte is a 'nil' MessagePack byte; false otherwise

func ReadArrayHeaderBytes

func ReadArrayHeaderBytes(b []byte) (sz int, isnil bool, o []byte, err error)

ReadArrayHeaderBytes attempts to read the array header size off of 'b' and return the size and remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not an array)

func ReadBoolBytes

func ReadBoolBytes(b []byte) (bool, []byte, error)

ReadBoolBytes tries to read a float64 from 'b' and return the value and the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a bool)

func ReadByteBytes

func ReadByteBytes(b []byte) (byte, []byte, error)

ReadByteBytes is analogous to ReadUint8Bytes

func ReadBytesBytes

func ReadBytesBytes(b []byte, scratch []byte) (v []byte, o []byte, err error)

ReadBytesBytes reads a 'bin' object from 'b' and returns its value and the remaining bytes in 'b'. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a 'bin' object)

func ReadBytesBytesHeader added in v1.1.44

func ReadBytesBytesHeader(b []byte) (sz int, err error)

ReadBytesBytesHeader reads the header of a 'bin' object from 'b' and return it's length, in bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a 'bin' object)

func ReadBytesZC

func ReadBytesZC(b []byte) (v []byte, o []byte, err error)

ReadBytesZC extracts the messagepack-encoded binary field without copying. The returned []byte points to the same memory as the input slice. Possible errors: - ErrShortBytes (b not long enough) - TypeError{} (object not 'bin')

func ReadComplex128Bytes

func ReadComplex128Bytes(b []byte) (c complex128, o []byte, err error)

ReadComplex128Bytes reads a complex128 extension object from 'b' and returns the remaining bytes. Possible errors: - ErrShortBytes (not enough bytes in 'b') - TypeError{} (object not a complex128) - InvalidPrefixError - ExtensionTypeError{} (object an extension of the correct size, but not a complex128)

func ReadComplex64Bytes

func ReadComplex64Bytes(b []byte) (c complex64, o []byte, err error)

ReadComplex64Bytes reads a complex64 extension object from 'b' and returns the remaining bytes. Possible errors: - ErrShortBytes (not enough bytes in 'b') - TypeError{} (object not a complex64) - ExtensionTypeError{} (object an extension of the correct size, but not a complex64)

func ReadDurationBytes added in v1.1.53

func ReadDurationBytes(b []byte) (d time.Duration, o []byte, err error)

ReadDurationBytes tries to read a time.Duration from 'b' and return the value and the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError (not a int)

func ReadExactBytes

func ReadExactBytes(b []byte, into []byte) (o []byte, err error)

func ReadExtensionBytes

func ReadExtensionBytes(b []byte, e Extension) ([]byte, error)

ReadExtensionBytes reads an extension from 'b' into 'e' and returns any remaining bytes. Possible errors: - ErrShortBytes ('b' not long enough) - ExtensionTypeError{} (wire type not the same as e.Type()) - TypeError{} (next object not an extension) - InvalidPrefixError - An umarshal error returned from e.UnmarshalBinary

func ReadFloat32Bytes

func ReadFloat32Bytes(b []byte) (f float32, o []byte, err error)

ReadFloat32Bytes tries to read a float64 from 'b' and return the value and the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a float32)

func ReadFloat64Bytes

func ReadFloat64Bytes(b []byte) (f float64, o []byte, err error)

ReadFloat64Bytes tries to read a float64 from 'b' and return the value and the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a float64)

func ReadInt16Bytes

func ReadInt16Bytes(b []byte) (int16, []byte, error)

ReadInt16Bytes tries to read an int16 from 'b' and return the value and the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a int) - IntOverflow{} (value doesn't fit in int16)

func ReadInt32Bytes

func ReadInt32Bytes(b []byte) (int32, []byte, error)

ReadInt32Bytes tries to read an int32 from 'b' and return the value and the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a int) - IntOverflow{} (value doesn't fit in int32)

func ReadInt64Bytes

func ReadInt64Bytes(b []byte) (i int64, o []byte, err error)

ReadInt64Bytes tries to read an int64 from 'b' and return the value and the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError (not a int)

func ReadInt8Bytes

func ReadInt8Bytes(b []byte) (int8, []byte, error)

ReadInt8Bytes tries to read an int16 from 'b' and return the value and the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a int) - IntOverflow{} (value doesn't fit in int8)

func ReadMapHeaderBytes

func ReadMapHeaderBytes(b []byte) (sz int, isnil bool, o []byte, err error)

ReadMapHeaderBytes reads a map header size from 'b' and returns the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a map)

func ReadMapKeyZC

func ReadMapKeyZC(b []byte) ([]byte, []byte, error)

ReadMapKeyZC attempts to read a map key from 'b' and returns the key bytes and the remaining bytes Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a str or bin)

func ReadNilBytes

func ReadNilBytes(b []byte) ([]byte, error)

ReadNilBytes tries to read a "nil" byte off of 'b' and return the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a 'nil') - InvalidPrefixError

func ReadStringAsBytes

func ReadStringAsBytes(b []byte, scratch []byte) (v []byte, o []byte, err error)

ReadStringAsBytes reads a 'str' object into a slice of bytes. 'v' is the value of the 'str' object, which may reside in memory pointed to by 'scratch.' 'o' is the remaining bytes in 'b'. Possible errors: - ErrShortBytes (b not long enough) - TypeError{} (not 'str' type) - InvalidPrefixError (unknown type marker)

func ReadStringBytes

func ReadStringBytes(b []byte) (string, []byte, error)

ReadStringBytes reads a 'str' object from 'b' and returns its value and the remaining bytes in 'b'. Possible errors: - ErrShortBytes (b not long enough) - TypeError{} (not 'str' type) - InvalidPrefixError

func ReadStringZC

func ReadStringZC(b []byte) (v []byte, o []byte, err error)

ReadStringZC reads a messagepack string field without copying. The returned []byte points to the same memory as the input slice. Possible errors: - ErrShortBytes (b not long enough) - TypeError{} (object not 'str')

func ReadTimeBytes

func ReadTimeBytes(b []byte) (t time.Time, o []byte, err error)

ReadTimeBytes reads a time.Time extension object from 'b' and returns the remaining bytes. Possible errors: - ErrShortBytes (not enough bytes in 'b') - TypeError{} (object not a complex64) - ExtensionTypeError{} (object an extension of the correct size, but not a time.Time)

func ReadUint16Bytes

func ReadUint16Bytes(b []byte) (uint16, []byte, error)

ReadUint16Bytes tries to read a uint16 from 'b' and return the value and the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a uint) - UintOverflow{} (value too large for uint16)

func ReadUint32Bytes

func ReadUint32Bytes(b []byte) (uint32, []byte, error)

ReadUint32Bytes tries to read a uint32 from 'b' and return the value and the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a uint) - UintOverflow{} (value too large for uint32)

func ReadUint64Bytes

func ReadUint64Bytes(b []byte) (u uint64, o []byte, err error)

ReadUint64Bytes tries to read a uint64 from 'b' and return the value and the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a uint)

func ReadUint8Bytes

func ReadUint8Bytes(b []byte) (uint8, []byte, error)

ReadUint8Bytes tries to read a uint8 from 'b' and return the value and the remaining bytes. Possible errors: - ErrShortBytes (too few bytes) - TypeError{} (not a uint) - UintOverflow{} (value too large for uint8)

func RegisterExtension

func RegisterExtension(typ int8, f func() Extension)

RegisterExtension registers extensions so that they can be initialized and returned by methods that decode `interface{}` values. This should only be called during initialization. f() should return a newly-initialized zero value of the extension. Keep in mind that extensions 3, 4, and 5 are reserved for complex64, complex128, and time.Time, respectively, and that MessagePack reserves extension types from -127 to -1.

For example, if you wanted to register a user-defined struct:

msgp.RegisterExtension(10, func() msgp.Extension { &MyExtension{} })

RegisterExtension will panic if you call it multiple times with the same 'typ' argument, or if you use a reserved type (3, 4, or 5).

func Require

func Require(old []byte, extra int) []byte

Require ensures that cap(old)-len(old) >= extra. It might be that this is impossible because len(old)+extra overflows int. If so, Require will not grow the slice, but at this point, we have run out of memory, and panic (from subsequent out-of-bounds access) is as good of an outcome as any.

func Resumable

func Resumable(e error) bool

Resumable returns whether or not the error means that the stream of data is malformed and the information is unrecoverable.

func Skip

func Skip(b []byte) ([]byte, error)

Skip skips the next object in 'b' and returns the remaining bytes. If the object is a map or array, all of its elements will be skipped. Possible Errors: - ErrShortBytes (not enough bytes in b) - InvalidPrefixError (bad encoding)

func WrapError

func WrapError(err error, ctx ...interface{}) error

WrapError wraps an error with additional context that allows the part of the serialized type that caused the problem to be identified. Underlying errors can be retrieved using Cause()

The input error is not modified - a new error should be returned.

ErrShortBytes is not wrapped with any context due to backward compatibility issues with the public API.

Types

type ArrayError

type ArrayError struct {
	Wanted int
	Got    int
	// contains filtered or unexported fields
}

ArrayError is an error returned when decoding a fix-sized array of the wrong size

func (ArrayError) Error

func (a ArrayError) Error() string

Error implements the error interface

func (ArrayError) Resumable

func (a ArrayError) Resumable() bool

Resumable is always 'true' for ArrayErrors

type ErrMaxDepthExceeded added in v1.1.59

type ErrMaxDepthExceeded struct{}

ErrMaxDepthExceeded is returned if the maximum traversal depth is exceeded.

func (ErrMaxDepthExceeded) Error added in v1.1.59

func (e ErrMaxDepthExceeded) Error() string

Error implements error

func (ErrMaxDepthExceeded) Resumable added in v1.1.59

func (e ErrMaxDepthExceeded) Resumable() bool

Resumable implements Error

type ErrNoField

type ErrNoField string

func (ErrNoField) Error

func (e ErrNoField) Error() string

type ErrTooManyArrayFields added in v1.1.19

type ErrTooManyArrayFields int

func (ErrTooManyArrayFields) Error added in v1.1.19

func (e ErrTooManyArrayFields) Error() string

type ErrUnsupportedType

type ErrUnsupportedType struct {
	T reflect.Type
	// contains filtered or unexported fields
}

ErrUnsupportedType is returned when a bad argument is supplied to a function that takes `interface{}`.

func (*ErrUnsupportedType) Error

func (e *ErrUnsupportedType) Error() string

Error implements error

func (*ErrUnsupportedType) Resumable

func (e *ErrUnsupportedType) Resumable() bool

Resumable returns 'true' for ErrUnsupportedType

type Error

type Error interface {
	error

	// Resumable returns whether
	// or not the error means that
	// the stream of data is malformed
	// and the information is unrecoverable.
	Resumable() bool
}

Error is the interface satisfied by all of the errors that originate from this package.

type Extension

type Extension interface {
	// ExtensionType should return
	// a int8 that identifies the concrete
	// type of the extension. (Types <0 are
	// officially reserved by the MessagePack
	// specifications.)
	ExtensionType() int8

	// Len should return the length
	// of the data to be encoded
	Len() int

	// MarshalBinaryTo should copy
	// the data into the supplied slice,
	// assuming that the slice has length Len()
	MarshalBinaryTo([]byte) error

	UnmarshalBinary([]byte) error
}

Extension is the interface fulfilled by types that want to define their own binary encoding.

type ExtensionTypeError

type ExtensionTypeError struct {
	Got  int8
	Want int8
}

ExtensionTypeError is an error type returned when there is a mis-match between an extension type and the type encoded on the wire

func (ExtensionTypeError) Error

func (e ExtensionTypeError) Error() string

Error implements the error interface

func (ExtensionTypeError) Resumable

func (e ExtensionTypeError) Resumable() bool

Resumable returns 'true' for ExtensionTypeErrors

type IntOverflow

type IntOverflow struct {
	Value         int64 // the value of the integer
	FailedBitsize int   // the bit size that the int64 could not fit into
	// contains filtered or unexported fields
}

IntOverflow is returned when a call would downcast an integer to a type with too few bits to hold its value.

func (IntOverflow) Error

func (i IntOverflow) Error() string

Error implements the error interface

func (IntOverflow) Resumable

func (i IntOverflow) Resumable() bool

Resumable is always 'true' for overflows

type InvalidPrefixError

type InvalidPrefixError byte

InvalidPrefixError is returned when a bad encoding uses a prefix that is not recognized in the MessagePack standard. This kind of error is unrecoverable.

func (InvalidPrefixError) Error

func (i InvalidPrefixError) Error() string

Error implements the error interface

func (InvalidPrefixError) Resumable

func (i InvalidPrefixError) Resumable() bool

Resumable returns 'false' for InvalidPrefixErrors

type Marshaler

type Marshaler interface {
	MarshalMsg([]byte) []byte
	CanMarshalMsg(o interface{}) bool
}

Marshaler is the interface implemented by types that know how to marshal themselves as MessagePack. MarshalMsg appends the marshalled form of the object to the provided byte slice, returning the extended slice. CanMarshalMsg checks that o is of the same type as was used to generate the MarshalMsg code; it can be used to guard against MarshalMsg() going to an embedded field in a struct rather than marshaling the entire struct.

type MaxSizer added in v1.1.55

type MaxSizer interface {
	MaxSize() int
}

MaxSizer is an interface implemented by types that can determine their max when implemented. This interface is optional, but implementations may use this as a way to limit number of bytes read during deserialization

type Raw

type Raw []byte

Raw is raw MessagePack. Raw allows you to read and write data without interpreting its contents.

func (Raw) CanMarshalMsg added in v1.1.40

func (Raw) CanMarshalMsg(z interface{}) bool

CanMarshalMsg returns true if the z interface is a Raw object ( part of the Marshaler interface )

func (*Raw) CanUnmarshalMsg added in v1.1.40

func (*Raw) CanUnmarshalMsg(z interface{}) bool

CanUnmarshalMsg returns true if the z interface is a Raw object ( part of the Unmarshaler interface )

func (Raw) MarshalMsg

func (r Raw) MarshalMsg(b []byte) []byte

MarshalMsg implements msgp.Marshaler. It appends the raw contents of 'raw' to the provided byte slice. If 'raw' is 0 bytes, 'nil' will be appended instead.

func (*Raw) MsgIsZero added in v1.1.40

func (r *Raw) MsgIsZero() bool

MsgIsZero returns whether this is a zero value

func (Raw) Msgsize

func (r Raw) Msgsize() int

Msgsize implements msgp.Sizer

func (*Raw) UnmarshalMsg

func (r *Raw) UnmarshalMsg(b []byte) ([]byte, error)

UnmarshalMsg implements msgp.Unmarshaler. It sets the contents of *Raw to be the next object in the provided byte slice.

func (*Raw) UnmarshalMsgWithState added in v1.1.59

func (r *Raw) UnmarshalMsgWithState(b []byte, st UnmarshalState) ([]byte, error)

UnmarshalMsg implements msgp.Unmarshaler. It sets the contents of *Raw to be the next object in the provided byte slice.

type RawExtension

type RawExtension struct {
	Data []byte
	Type int8
}

RawExtension implements the Extension interface

func (*RawExtension) ExtensionType

func (r *RawExtension) ExtensionType() int8

ExtensionType implements Extension.ExtensionType, and returns r.Type

func (*RawExtension) Len

func (r *RawExtension) Len() int

Len implements Extension.Len, and returns len(r.Data)

func (*RawExtension) MarshalBinaryTo

func (r *RawExtension) MarshalBinaryTo(d []byte) error

MarshalBinaryTo implements Extension.MarshalBinaryTo, and returns a copy of r.Data

func (*RawExtension) UnmarshalBinary

func (r *RawExtension) UnmarshalBinary(b []byte) error

UnmarshalBinary implements Extension.UnmarshalBinary, and sets r.Data to the contents of the provided slice

type Sizer

type Sizer interface {
	Msgsize() int
}

Sizer is an interface implemented by types that can estimate their size when MessagePack encoded. This interface is optional, but encoding/marshaling implementations may use this as a way to pre-allocate memory for serialization.

type Type

type Type byte

Type is a MessagePack wire type, including this package's built-in extension types.

const (
	InvalidType Type = iota

	StrType
	BinType
	MapType
	ArrayType
	Float64Type
	Float32Type
	BoolType
	IntType
	UintType
	NilType
	ExtensionType

	Complex64Type
	Complex128Type
	TimeType
)

MessagePack Types

The zero value of Type is InvalidType.

func NextType

func NextType(b []byte) Type

NextType returns the type of the next object in the slice. If the length of the input is zero, it returns InvalidType.

func (Type) String

func (t Type) String() string

String implements fmt.Stringer

type TypeError

type TypeError struct {
	Method  Type // Type expected by method
	Encoded Type // Type actually encoded
	// contains filtered or unexported fields
}

A TypeError is returned when a particular decoding method is unsuitable for decoding a particular MessagePack value.

func (TypeError) Error

func (t TypeError) Error() string

Error implements the error interface

func (TypeError) Resumable

func (t TypeError) Resumable() bool

Resumable returns 'true' for TypeErrors

type UintBelowZero

type UintBelowZero struct {
	Value int64 // value of the incoming int
	// contains filtered or unexported fields
}

UintBelowZero is returned when a call would cast a signed integer below zero to an unsigned integer.

func (UintBelowZero) Error

func (u UintBelowZero) Error() string

Error implements the error interface

func (UintBelowZero) Resumable

func (u UintBelowZero) Resumable() bool

Resumable is always 'true' for overflows

type UintOverflow

type UintOverflow struct {
	Value         uint64 // value of the uint
	FailedBitsize int    // the bit size that couldn't fit the value
	// contains filtered or unexported fields
}

UintOverflow is returned when a call would downcast an unsigned integer to a type with too few bits to hold its value

func (UintOverflow) Error

func (u UintOverflow) Error() string

Error implements the error interface

func (UintOverflow) Resumable

func (u UintOverflow) Resumable() bool

Resumable is always 'true' for overflows

type UnmarshalState added in v1.1.59

type UnmarshalState struct {
	AllowableDepth uint64
}

UnmarshalState holds state while running UnmarshalMsg.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalMsg([]byte) ([]byte, error)
	UnmarshalMsgWithState([]byte, UnmarshalState) ([]byte, error)
	CanUnmarshalMsg(o interface{}) bool
}

Unmarshaler is the interface fulfilled by objects that know how to unmarshal themselves from MessagePack. UnmarshalMsg unmarshals the object from binary, returing any leftover bytes and any errors encountered. CanUnmarshalMsg checks that o is of the same type as was used to generate the UnmarshalMsg code; it can be used to guard against UnmarshalMsg() going to an embedded field in a struct rather than unmarshaling the entire struct.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL