UnmarshalMsg decodes the message from the bytes.
(bytes []byte)
| 1089 | |
| 1090 | // UnmarshalMsg decodes the message from the bytes. |
| 1091 | func (s *ByteSorted) UnmarshalMsg(bytes []byte) ([]byte, error) { |
| 1092 | if msgp.IsNil(bytes) { |
| 1093 | *s = nil |
| 1094 | return bytes[msgp.NilSize:], nil |
| 1095 | } |
| 1096 | // Read the array header |
| 1097 | sz, bytes, err := msgp.ReadArrayHeaderBytes(bytes) |
| 1098 | if err != nil { |
| 1099 | return nil, err |
| 1100 | } |
| 1101 | dst := *s |
| 1102 | if dst == nil { |
| 1103 | dst = make(ByteSorted, sz) |
| 1104 | } else { |
| 1105 | clear(dst) |
| 1106 | } |
| 1107 | for range sz { |
| 1108 | var k byte |
| 1109 | k, bytes, err = msgp.ReadByteBytes(bytes) |
| 1110 | if err != nil { |
| 1111 | return nil, err |
| 1112 | } |
| 1113 | dst[byte(k)] = struct{}{} |
| 1114 | } |
| 1115 | *s = dst |
| 1116 | return bytes, nil |
| 1117 | } |
| 1118 | |
| 1119 | // Msgsize returns the maximum size of the message. |
| 1120 | func (s ByteSorted) Msgsize() int { |