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

Method DecodeMsg

msgp/setof/generated.go:63–88  ·  view source on GitHub ↗

DecodeMsg decodes the message from the reader.

(reader *msgp.Reader)

Source from the content-addressed store, hash-verified

61
62// DecodeMsg decodes the message from the reader.
63func (s *String) DecodeMsg(reader *msgp.Reader) error {
64 if reader.IsNil() {
65 *s = nil
66 return reader.Skip()
67 }
68 sz, err := reader.ReadArrayHeader()
69 if err != nil {
70 return err
71 }
72 dst := *s
73 if dst == nil {
74 dst = make(String, sz)
75 } else {
76 clear(dst)
77 }
78 for range sz {
79 var k string
80 k, err = reader.ReadString()
81 if err != nil {
82 return err
83 }
84 dst[string(k)] = struct{}{}
85 }
86 *s = dst
87 return nil
88}
89
90// UnmarshalMsg decodes the message from the bytes.
91func (s *String) UnmarshalMsg(bytes []byte) ([]byte, error) {

Callers 4

TestString_RoundTripFunction · 0.95
TestString_NilHandlingFunction · 0.95
TestString_EmptySetFunction · 0.95

Calls 4

IsNilMethod · 0.80
SkipMethod · 0.80
ReadArrayHeaderMethod · 0.80
ReadStringMethod · 0.80

Tested by 4

TestString_RoundTripFunction · 0.76
TestString_NilHandlingFunction · 0.76
TestString_EmptySetFunction · 0.76