MCPcopy
hub / github.com/tinylib/msgp / DecodeMsg

Method DecodeMsg

msgp/number.go:104–141  ·  view source on GitHub ↗

DecodeMsg implements msgp.Decodable

(r *Reader)

Source from the content-addressed store, hash-verified

102
103// DecodeMsg implements msgp.Decodable
104func (n *Number) DecodeMsg(r *Reader) error {
105 typ, err := r.NextType()
106 if err != nil {
107 return err
108 }
109 switch typ {
110 case Float32Type:
111 f, err := r.ReadFloat32()
112 if err != nil {
113 return err
114 }
115 n.AsFloat32(f)
116 return nil
117 case Float64Type:
118 f, err := r.ReadFloat64()
119 if err != nil {
120 return err
121 }
122 n.AsFloat64(f)
123 return nil
124 case IntType:
125 i, err := r.ReadInt64()
126 if err != nil {
127 return err
128 }
129 n.AsInt(i)
130 return nil
131 case UintType:
132 u, err := r.ReadUint64()
133 if err != nil {
134 return err
135 }
136 n.AsUint(u)
137 return nil
138 default:
139 return TypeError{Encoded: typ, Method: IntType}
140 }
141}
142
143// UnmarshalMsg implements msgp.Unmarshaler
144func (n *Number) UnmarshalMsg(b []byte) ([]byte, error) {

Callers

nothing calls this directly

Calls 9

AsFloat32Method · 0.95
AsFloat64Method · 0.95
AsIntMethod · 0.95
AsUintMethod · 0.95
NextTypeMethod · 0.80
ReadFloat32Method · 0.80
ReadFloat64Method · 0.80
ReadInt64Method · 0.80
ReadUint64Method · 0.80

Tested by

no test coverage detected