in internal/encoding/types.go [605:666]
func (a *arrayUint32) Unmarshal(r *buffer.Buffer) error {
length, err := readArrayHeader(r)
if err != nil {
return err
}
aa := (*a)[:0]
type_, err := readType(r)
if err != nil {
return err
}
switch type_ {
case TypeCodeUint0:
if int64(cap(aa)) < length {
aa = make([]uint32, length)
} else {
aa = aa[:length]
for i := range aa {
aa[i] = 0
}
}
case TypeCodeSmallUint:
buf, ok := r.Next(length)
if !ok {
return errors.New("invalid length")
}
if int64(cap(aa)) < length {
aa = make([]uint32, length)
} else {
aa = aa[:length]
}
for i, n := range buf {
aa[i] = uint32(n)
}
case TypeCodeUint:
const typeSize = 4
buf, ok := r.Next(length * typeSize)
if !ok {
return fmt.Errorf("invalid length %d", length)
}
if int64(cap(aa)) < length {
aa = make([]uint32, length)
} else {
aa = aa[:length]
}
var bufIdx int
for i := range aa {
aa[i] = binary.BigEndian.Uint32(buf[bufIdx : bufIdx+4])
bufIdx += 4
}
default:
return fmt.Errorf("invalid type for []uint32 %02x", type_)
}
*a = aa
return nil
}