func validatePUBACKBytes(fixedHeader FixedHeader, variableHeader []byte) error {
	ptype, err := fixedHeader.ptype()
	if err != nil {
		return err
	}
	if len(fixedHeader) != lenPUBACKFixedHeader {
		return ErrInvalidFixedHeaderLen
	}
	if ptype != TypePUBACK {
		return ErrInvalidPacketType
	}
	if fixedHeader[0]<<4 != 0x00 {
		return ErrInvalidFixedHeader
	}
	if fixedHeader[1] != lenPUBACKVariableHeader {
		return ErrInvalidRemainingLength
	}
	if len(variableHeader) != lenPUBACKVariableHeader {
		return ErrInvalidVariableHeaderLen
	}
	packetID, _ := decodeUint16(variableHeader)
	if packetID == 0 {
		return ErrInvalidPacketID
	}
	return nil
}
validatePUBACKBytes validates the fixed header and the variable header.
package packet
const lenPUBACKFixedHeader = 2
const lenPUBACKVariableHeader = 2
type PUBACK struct {
	base
	PacketID uint16
}
func (p *PUBACK) setFixedHeader() {
	p.fixedHeader = append(p.fixedHeader, TypePUBACK<<4)
	p.appendRemainingLength()
}
func (p *PUBACK) setVariableHeader() {
	p.variableHeader = append(p.variableHeader, encodeUint16(p.PacketID)...)
}
func NewPUBACK(opts *PUBACKOptions) (Packet, error) {
	if opts == nil {
		opts = &PUBACKOptions{}
	}
	if err := opts.validate(); err != nil {
		return nil, err
	}
	p := &PUBACK{
		PacketID: opts.PacketID,
	}
	p.setVariableHeader()
	p.setFixedHeader()
	return p, nil
}
func NewPUBACKFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error) {
	if err := validatePUBACKBytes(fixedHeader, variableHeader); err != nil {
		return nil, err
	}
	packetID, _ := decodeUint16(variableHeader)
	p := &PUBACK{
		PacketID: packetID,
	}
	p.fixedHeader = fixedHeader
	p.variableHeader = variableHeader
	return p, nil
}