UnmarshalMsg decodes the message from the bytes.
(bytes []byte)
| 363 | |
| 364 | // UnmarshalMsg decodes the message from the bytes. |
| 365 | func (s *Int) UnmarshalMsg(bytes []byte) ([]byte, error) { |
| 366 | if msgp.IsNil(bytes) { |
| 367 | *s = nil |
| 368 | return bytes[msgp.NilSize:], nil |
| 369 | } |
| 370 | // Read the array header |
| 371 | sz, bytes, err := msgp.ReadArrayHeaderBytes(bytes) |
| 372 | if err != nil { |
| 373 | return nil, err |
| 374 | } |
| 375 | dst := *s |
| 376 | if dst == nil { |
| 377 | dst = make(Int, sz) |
| 378 | } else { |
| 379 | clear(dst) |
| 380 | } |
| 381 | for range sz { |
| 382 | var k int |
| 383 | k, bytes, err = msgp.ReadIntBytes(bytes) |
| 384 | if err != nil { |
| 385 | return nil, err |
| 386 | } |
| 387 | dst[int(k)] = struct{}{} |
| 388 | } |
| 389 | *s = dst |
| 390 | return bytes, nil |
| 391 | } |
| 392 | |
| 393 | // Msgsize returns the maximum size of the message. |
| 394 | func (s Int) Msgsize() int { |