// UnmarshalBinary implements encoding.BinaryUnmarshaler.
// Preserves the hasher.
3745
func (h *HLL) UnmarshalBinary(data []byte) error {
	var s serializable
	err := gob.NewDecoder(bytes.NewReader(data)).Decode(&s)
	if err != nil {
		return err
	}
	h.P = s.P
	h.m1 = s.M1
	h.m2 = s.M2
	h.alpha = s.Alpha
	h.format = s.Format
	h.tempSet = &s.TempSet
	h.sparseList = &s.SparseList
	h.registers = s.Registers

	if h.Hasher == nil {
		h.Hasher = MMH3Hash
	}
	return nil
}
855720
func (eui *EUI64) UnmarshalBinary(data []byte) error {
	if len(data) != 8 {
		return errors.New("ttn/core: Invalid length for EUI64")
	}
	copy(eui[:], data)
	return nil
}
1249398
func (v *mvccValue) UnmarshalBinary(data []byte) error {
	var mh marshalHelper
	buf := bytes.NewBuffer(data)
	var vt int64
	mh.ReadNumber(buf, &vt)
	v.valueType = mvccValueType(vt)
	mh.ReadNumber(buf, &v.startTS)
	mh.ReadNumber(buf, &v.commitTS)
	mh.ReadSlice(buf, &v.value)
	return errors.Trace(mh.err)
}
1319220
func (id *ULID) UnmarshalBinary(data []byte) error {
	if len(data) != len(*id) {
		return ErrDataSize
	}

	copy((*id)[:], data)
	return nil
}
170283
func (s *SubnetMask) UnmarshalBinary(p []byte) error {
	buf := uio.NewBigEndianBuffer(p)
	*s = buf.CopyN(net.IPv4len)
	return buf.FinError()
}
586721
func (u *UUID) UnmarshalBinary(data []byte) error {
	if len(data) == 0 {
		return nil
	}
	if len(data) != 16 {
		return fmt.Errorf("invalid UUID (got %d bytes)", len(data))
	}
	var id [16]byte
	copy(id[:], data)
	*u = id[:]
	return nil
}
382985
func (p *FragSessionSetupAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) < p.Size() {
		return fmt.Errorf("lorawan/applayer/fragmentation: %d byte is expected", p.Size())
	}

	p.StatusBitMask.EncodingUnsupported = data[0]&0x01 != 0
	p.StatusBitMask.NotEnoughMemory = data[0]&0x02 != 0
	p.StatusBitMask.FragSessionIndexNotSupported = data[0]&0x04 != 0
	p.StatusBitMask.WrongDescriptor = data[0]&0x08 != 0
	p.StatusBitMask.FragIndex = (data[0] >> 6) & 0x03

	return nil
}
744646
func (i *IP) UnmarshalBinary(b []byte) error {
	if len(b) != net.IPv6len {
		return io.ErrUnexpectedEOF
	}

	if ip := net.IP(b); ip.To4() != nil {
		return io.ErrUnexpectedEOF
	}

	*i = make(IP, net.IPv6len)
	copy(*i, b)
	return nil
}
862475
func (p *LinkADRAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}
	if data[0]&(1<<0) > 0 {
		p.ChannelMaskACK = true
	}
	if data[0]&(1<<1) > 0 {
		p.DataRateACK = true
	}
	if data[0]&(1<<2) > 0 {
		p.PowerACK = true
	}
	return nil
}
49440
func (r *RequestSetattrV2) UnmarshalBinary(data []byte) error {
	return UnmarshalBinary(data, &r.Request, &r.Hints, &r.Attr, &r.Handle, &r.FileName)
}
479269
func (meta *Meta) UnmarshalBinary(data []byte) error {
	return meta.ReadBinary(bytes.NewReader(data))
}
368441
func (r *SetSystemBootOptionsRequest) UnmarshalBinary(buf []byte) error {
	if len(buf) < 2 {
		return ErrShortPacket
	}
	r.Param = buf[0]
	r.Data = buf[1:]
	if l, ok := validSetBootOptionsDataLength[r.Param]; ok {
		if len(r.Data) < l {
			return ErrShortPacket
		}
	}
	return nil
}
941283
func (w *DeleteBucketRangeWALEntry) UnmarshalBinary(b []byte) error {
	if len(b) != 2*influxdb.IDLength+16 {
		return ErrWALCorrupt
	}

	if err := w.OrgID.Decode(b[0:influxdb.IDLength]); err != nil {
		return err
	}
	if err := w.BucketID.Decode(b[influxdb.IDLength : 2*influxdb.IDLength]); err != nil {
		return err
	}
	w.Min = int64(binary.BigEndian.Uint64(b[2*influxdb.IDLength : 2*influxdb.IDLength+8]))
	w.Max = int64(binary.BigEndian.Uint64(b[2*influxdb.IDLength+8 : 2*influxdb.IDLength+16]))

	return nil
}
260689
func (e *EUI64) UnmarshalBinary(data []byte) error {
	if len(data) != len(e) {
		return fmt.Errorf("lorawan: %d bytes of data are expected", len(e))
	}
	for i, v := range data {
		// little endian
		e[len(e)-i-1] = v
	}
	return nil
}
614619
func (b *BitSet) UnmarshalBinary(data []byte) error {
	buf := bytes.NewReader(data)
	reader := bufio.NewReader(buf)

	_, err := b.ReadFrom(reader)

	return err
}
700438
func (r *Redundancy) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}
	r.NbRep = data[0] & ((1 << 3) ^ (1 << 2) ^ (1 << 1) ^ (1 << 0))
	r.ChMaskCntl = (data[0] & ((1 << 6) ^ (1 << 5) ^ (1 << 4))) >> 4
	return nil
}
440771
func (a *Authentication) UnmarshalBinary(p []byte) error {
	b := buffer.New(p)
	// Too short to be valid Authentication
	if b.Len() < 11 {
		return io.ErrUnexpectedEOF
	}

	a.Protocol = b.Read8()
	a.Algorithm = b.Read8()
	a.RDM = b.Read8()
	a.ReplayDetection = b.Read64()
	a.AuthenticationInformation = b.Remaining()
	return nil
}