// UnmarshalBinary unmarshals a raw byte slice into a StatusCode.
//
// If the byte slice does not contain enough data to form a valid StatusCode,
// errInvalidStatusCode is returned.
348591
func (s *StatusCode) UnmarshalBinary(p []byte) error {
	b := buffer.New(p)
	// Too short to contain valid StatusCode
	if b.Len() < 2 {
		return io.ErrUnexpectedEOF
	}

	s.Code = dhcp6.Status(b.Read16())
	s.Message = string(b.Remaining())
	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)
}
424340
func (p *ADRParamSetupReqPayload) UnmarshalBinary(data []byte) error {
	return p.ADRParam.UnmarshalBinary(data)
}
111633
func (po *Po) UnmarshalBinary(data []byte) error {
	buff := bytes.NewBuffer(data)
	obj := new(TranslatorEncoding)

	decoder := gob.NewDecoder(buff)
	err := decoder.Decode(obj)
	if err != nil {
		return err
	}

	po.Headers = obj.Headers
	po.Language = obj.Language
	po.PluralForms = obj.PluralForms
	po.nplurals = obj.Nplurals
	po.plural = obj.Plural
	po.translations = obj.Translations
	po.contexts = obj.Contexts

	if expr, err := plurals.Compile(po.plural); err == nil {
		po.pluralforms = expr
	}

	return nil
}
222077
func (h *Header) UnmarshalBinary(data []byte) error {
	buf := bytes.NewBuffer(data)

	err := binary.Read(buf, binary.LittleEndian, h)
	if err != nil {
		return fmt.Errorf("reading hgfs header: %s", err)
	}

	if h.Dummy != OpNewHeader {
		return fmt.Errorf("expected hgfs header with OpNewHeader (%#x), got: %#x", OpNewHeader, h.Dummy)
	}

	return nil
}
183517
func (r *RequestCreateSessionV4) UnmarshalBinary(data []byte) error {
	buf := bytes.NewBuffer(data)

	fields := []*uint32{
		&r.NumCapabilities,
		&r.MaxPacketSize,
		&r.Flags,
		&r.Reserved,
	}

	for _, p := range fields {
		err := binary.Read(buf, binary.LittleEndian, p)
		if err != nil {
			return err
		}
	}

	for i := uint32(0); i < r.NumCapabilities; i++ {
		var cap Capability
		err := binary.Read(buf, binary.LittleEndian, &cap)
		if err != nil {
			return err
		}

		r.Capabilities = append(r.Capabilities, cap)
	}

	return nil
}
54213
func (p *LinkCheckAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 2 {
		return errors.New("lorawan: 2 bytes of data are expected")
	}
	p.Margin = uint8(data[0])
	p.GwCnt = uint8(data[1])
	return nil
}
647332
func (p *FragSessionDeleteAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) < p.Size() {
		return fmt.Errorf("lorawan/applayer/fragmentation: %d byte is expected", p.Size())
	}

	p.Status.FragIndex = data[0] & 0x03
	p.Status.SessionDoesNotExist = data[0]&0x04 != 0

	return nil
}
911664
func (l *Locale) UnmarshalBinary(data []byte) error {
	buff := bytes.NewBuffer(data)
	obj := new(LocaleEncoding)

	decoder := gob.NewDecoder(buff)
	err := decoder.Decode(obj)
	if err != nil {
		return err
	}

	l.defaultDomain = obj.DefaultDomain
	l.lang = obj.Lang
	l.path = obj.Path

	// Decode Domains
	l.Domains = make(map[string]Translator)
	for k, v := range obj.Domains {
		var tr TranslatorEncoding
		buff := bytes.NewBuffer(v)
		trDecoder := gob.NewDecoder(buff)
		err := trDecoder.Decode(&tr)
		if err != nil {
			return err
		}

		l.Domains[k] = tr.GetTranslator()
	}

	return nil
}
696228
func (p *ResetIndPayload) UnmarshalBinary(data []byte) error {
	return p.DevLoRaWANVersion.UnmarshalBinary(data)
}
1311366
func (p *McGroupStatusReqPayload) UnmarshalBinary(data []byte) error {
	if len(data) < p.Size() {
		return fmt.Errorf("lorawan/applayer/multicastsetup: %d bytes are expected", p.Size())
	}

	for i := range p.CmdMask.RegGroupMask {
		p.CmdMask.RegGroupMask[i] = data[0]&(1<<uint8(i)) != 0
	}

	return nil
}
707542
func (a *App) UnmarshalBinary(b []byte) error {
	return json.Unmarshal(b, a)
}
250372
func (h *TLFWriterKeyBundleID) UnmarshalBinary(data []byte) error {
	return h.h.UnmarshalBinary(data)
}
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
}
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
}
955093
func (p *DLChannelReqPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 4 {
		return errors.New("lorawan: 4 bytes of data are expected")
	}

	p.ChIndex = data[0]
	b := make([]byte, 4)
	copy(b, data[1:])
	p.Freq = binary.LittleEndian.Uint32(b) * 100
	return nil
}
1263313
func (p *ProprietaryMACCommandPayload) UnmarshalBinary(data []byte) error {
	p.Bytes = data
	return nil
}