UnmarshalMsg decodes the message from the bytes.
(bytes []byte)
| 232 | |
| 233 | // UnmarshalMsg decodes the message from the bytes. |
| 234 | func (s *StringSorted) UnmarshalMsg(bytes []byte) ([]byte, error) { |
| 235 | if msgp.IsNil(bytes) { |
| 236 | *s = nil |
| 237 | return bytes[msgp.NilSize:], nil |
| 238 | } |
| 239 | // Read the array header |
| 240 | sz, bytes, err := msgp.ReadArrayHeaderBytes(bytes) |
| 241 | if err != nil { |
| 242 | return nil, err |
| 243 | } |
| 244 | dst := *s |
| 245 | if dst == nil { |
| 246 | dst = make(StringSorted, sz) |
| 247 | } else { |
| 248 | clear(dst) |
| 249 | } |
| 250 | for range sz { |
| 251 | var k string |
| 252 | k, bytes, err = msgp.ReadStringBytes(bytes) |
| 253 | if err != nil { |
| 254 | return nil, err |
| 255 | } |
| 256 | dst[string(k)] = struct{}{} |
| 257 | } |
| 258 | *s = dst |
| 259 | return bytes, nil |
| 260 | } |
| 261 | |
| 262 | // Msgsize returns the maximum size of the message. |
| 263 | func (s StringSorted) Msgsize() int { |