-
Notifications
You must be signed in to change notification settings - Fork 14
/
read.go
91 lines (80 loc) · 1.78 KB
/
read.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package msgp
// Type is a MessagePack wire type,
// including this package's built-in
// extension types.
type Type byte
// MessagePack Types
//
// The zero value of Type
// is InvalidType.
const (
InvalidType Type = iota
// MessagePack built-in types
StrType
BinType
MapType
ArrayType
Float64Type
Float32Type
BoolType
IntType
UintType
NilType
ExtensionType
// pseudo-types provided
// by extensions
Complex64Type
Complex128Type
TimeType
_maxtype
)
// String implements fmt.Stringer
func (t Type) String() string {
switch t {
case StrType:
return "str"
case BinType:
return "bin"
case MapType:
return "map"
case ArrayType:
return "array"
case Float64Type:
return "float64"
case Float32Type:
return "float32"
case BoolType:
return "bool"
case UintType:
return "uint"
case IntType:
return "int"
case ExtensionType:
return "ext"
case NilType:
return "nil"
default:
return "<invalid>"
}
}
// 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.
type Unmarshaler interface {
UnmarshalMsg([]byte) ([]byte, error)
UnmarshalMsgWithState([]byte, UnmarshalState) ([]byte, error)
CanUnmarshalMsg(o interface{}) bool
}
// UnmarshalState holds state while running UnmarshalMsg.
type UnmarshalState struct {
AllowableDepth uint64
}
// DefaultUnmarshalState defines the default state.
var DefaultUnmarshalState = UnmarshalState{AllowableDepth: 10000}