UnmarshalMsg decodes the message from the bytes.
(bytes []byte)
| 89 | |
| 90 | // UnmarshalMsg decodes the message from the bytes. |
| 91 | func (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. |
| 120 | func (s String) Msgsize() int { |