// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
// for ID.
197485
func (id *ID) UnmarshalBinary(data []byte) error {
	if len(data) != idByteLen {
		return errors.WithStack(
			InvalidIDError{hex.EncodeToString(data)})
	}
	suffix := data[idByteLen-1]
	if suffix != idSuffix && suffix != pubIDSuffix &&
		suffix != singleTeamIDSuffix {
		return errors.WithStack(
			InvalidIDError{hex.EncodeToString(data)})
	}
	copy(id.id[:], data)
	return nil
}
138664
func (n *DevNonce) UnmarshalBinary(data []byte) error {
	if len(data) != 2 {
		return errors.New("lorawan: 2 bytes are expected")
	}
	*n = DevNonce(binary.LittleEndian.Uint16(data))
	return nil
}
211659
func (p *McGroupDeleteAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) < p.Size() {
		return fmt.Errorf("lorawan/applayer/multicastsetup: %d bytes are expected", p.Size())
	}

	p.McGroupIDHeader.McGroupID = data[0] & 0x03
	p.McGroupIDHeader.McGroupUndefined = data[0]&0x04 != 0

	return nil
}
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
}
474980
func (v *Value) UnmarshalBinary(data []byte) error {
	reader := bytes.NewReader(data)

	b, err := reader.ReadByte()
	if err != nil {
		return err
	}

	typ := ValueType(b)
	if typ == NullType {
		*v = Value{}
		return nil
	}

	length, err := binary.ReadUvarint(reader)
	if err != nil {
		return err
	}

	raw := make([]byte, length)
	n, err := reader.Read(raw)
	if err != nil {
		return err
	}

	if uint64(n) != length {
		return errors.Newf("Not enough bytes to read Value")
	}

	switch typ {
	case NumericType:
		*v = Value{Numeric(raw)}
	case FractionalType:
		*v = Value{Fractional(raw)}
	case StringType:
		*v = Value{String{raw, false}}
	case UTF8StringType:
		*v = Value{String{raw, true}}
	default:
		return errors.Newf("Unknown type %d", int(typ))
	}

	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
}
1256912
func (u *Array) UnmarshalBinary(data []byte) error {
	if len(data) != 16 {
		return fmt.Errorf("invalid UUID (got %d bytes)", len(data))
	}
	copy(u[:], data)
	return nil
}
327240
func (n *NII) UnmarshalBinary(b []byte) error {
	// Length must be exactly 3
	if len(b) != 3 {
		return io.ErrUnexpectedEOF
	}

	n.Type = b[0]
	n.Major = b[1]
	n.Minor = b[2]

	return nil
}
100219
func (f *FileName) UnmarshalBinary(data []byte) error {
	buf := bytes.NewBuffer(data)

	_ = binary.Read(buf, binary.LittleEndian, &f.Length)

	f.Name = string(buf.Next(int(f.Length)))

	return nil
}
586419
func (u *UUID) UnmarshalBinary(data []byte) (err error) {
	if len(data) != Size {
		err = fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data))
		return
	}
	copy(u[:], data)

	return
}
424841
func (p *BeaconFreqAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}

	p.BeaconFrequencyOK = data[0]&(1<<0) != 0

	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
}
668152
func (u *Uint32) UnmarshalBinary(p []byte) error {
	b := uio.NewBigEndianBuffer(p)
	*u = Uint32(b.Read32())
	return b.FinError()
}
522878
func (o *UUID) UnmarshalBinary(bytes []byte) error {
	if len(bytes) != o.Size() {
		return errors.New("uuid: invalid length")
	}
	o.unmarshal(bytes)
	return nil
}
301669
func (d *Data) UnmarshalBinary(p []byte) error {
	b := buffer.New(p)
	return d.Unmarshal(b)
}
1263313
func (p *ProprietaryMACCommandPayload) UnmarshalBinary(data []byte) error {
	p.Bytes = data
	return nil
}
944649
func (n *JoinNonce) UnmarshalBinary(data []byte) error {
	if len(data) != 3 {
		return errors.New("lorawan: 3 bytes are expected")
	}

	b := make([]byte, 4)
	copy(b[:3], data)
	*n = JoinNonce(binary.LittleEndian.Uint32(b))

	return nil
}