(data []byte)
| 249 | } |
| 250 | |
| 251 | func (s *UUIDSet) decode(data []byte) (int, error) { |
| 252 | if len(data) < 24 { |
| 253 | return 0, errors.Errorf("invalid uuid set buffer, less 24") |
| 254 | } |
| 255 | |
| 256 | pos := 0 |
| 257 | var err error |
| 258 | if s.SID, err = uuid.FromBytes(data[0:16]); err != nil { |
| 259 | return 0, err |
| 260 | } |
| 261 | pos += 16 |
| 262 | |
| 263 | n := int64(binary.LittleEndian.Uint64(data[pos : pos+8])) |
| 264 | pos += 8 |
| 265 | if len(data) < int(16*n)+pos { |
| 266 | return 0, errors.Errorf("invalid uuid set buffer, must %d, but %d", pos+int(16*n), len(data)) |
| 267 | } |
| 268 | |
| 269 | s.Intervals = make([]Interval, 0, n) |
| 270 | |
| 271 | var in Interval |
| 272 | for i := int64(0); i < n; i++ { |
| 273 | in.Start = int64(binary.LittleEndian.Uint64(data[pos : pos+8])) |
| 274 | pos += 8 |
| 275 | in.Stop = int64(binary.LittleEndian.Uint64(data[pos : pos+8])) |
| 276 | pos += 8 |
| 277 | s.Intervals = append(s.Intervals, in) |
| 278 | } |
| 279 | |
| 280 | return pos, nil |
| 281 | } |
| 282 | |
| 283 | func (s *UUIDSet) Decode(data []byte) error { |
| 284 | n, err := s.decode(data) |
no outgoing calls
no test coverage detected