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

Method UnmarshalMsg

msgp/setof/generated.go:91–117  ·  view source on GitHub ↗

UnmarshalMsg decodes the message from the bytes.

(bytes []byte)

Source from the content-addressed store, hash-verified

89
90// UnmarshalMsg decodes the message from the bytes.
91func (s *String) UnmarshalMsg(bytes []byte) ([]byte, error) {
92 if msgp.IsNil(bytes) {
93 *s = nil
94 return bytes[msgp.NilSize:], nil
95 }
96 // Read the array header
97 sz, bytes, err := msgp.ReadArrayHeaderBytes(bytes)
98 if err != nil {
99 return nil, err
100 }
101 dst := *s
102 if dst == nil {
103 dst = make(String, sz)
104 } else {
105 clear(dst)
106 }
107 for range sz {
108 var k string
109 k, bytes, err = msgp.ReadStringBytes(bytes)
110 if err != nil {
111 return nil, err
112 }
113 dst[string(k)] = struct{}{}
114 }
115 *s = dst
116 return bytes, nil
117}
118
119// Msgsize returns the maximum size of the message.
120func (s String) Msgsize() int {

Callers 4

TestString_RoundTripFunction · 0.95
TestString_NilHandlingFunction · 0.95
TestString_EmptySetFunction · 0.95

Calls 3

IsNilFunction · 0.92
ReadArrayHeaderBytesFunction · 0.92
ReadStringBytesFunction · 0.92

Tested by 4

TestString_RoundTripFunction · 0.76
TestString_NilHandlingFunction · 0.76
TestString_EmptySetFunction · 0.76