func (p *Pubcomp) Decode(src []byte) (int, error) {
	return identifiedDecode(src, &p.ID, PUBCOMP)
}
Decode reads from the byte slice argument. It returns the total number of
bytes decoded, and whether there have been any errors during the process.
package packet
import (
	"fmt"
)
func identifiedLen() int {
	return headerLen(2) + 2
}
func identifiedDecode(src []byte, id *ID, t Type) (int, error) {
	total, _, rl, err := decodeHeader(src, t)
	if err != nil {
		return total, err
	}
	if rl != 2 {
		return total, makeError(t, "expected remaining length to be 2")
	}
	pid, n, err := readUint(src[total:], 2, t)
	total += n
	if err != nil {
		return total, err
	}
	packetID := ID(pid)
	if !packetID.Valid() {
		return total, makeError(t, "packet id must be grater than zero")
	}
	*id = packetID
	return total, nil
}
func identifiedEncode(dst []byte, id ID, t Type) (int, error) {
	if !id.Valid() {
		return 0, makeError(t, "packet id must be grater than zero")
	}
	total, err := encodeHeader(dst, 0, 2, identifiedLen(), t)
	if err != nil {
		return total, err
	}
	n, err := writeUint(dst[total:], uint64(id), 2, t)
	total += n
	if err != nil {
		return total, err
	}
	return total, nil
}
type Puback struct {
	ID ID
}
func NewPuback() *Puback {
	return &Puback{}
}
func (p *Puback) Type() Type {
	return PUBACK
}
func (p *Puback) Len() int {
	return identifiedLen()
}
func (p *Puback) Decode(src []byte) (int, error) {
	return identifiedDecode(src, &p.ID, PUBACK)
}
func (p *Puback) Encode(dst []byte) (int, error) {
	return identifiedEncode(dst, p.ID, PUBACK)
}
func (p *Puback) String() string {
	return fmt.Sprintf("<Puback ID=%d>", p.ID)
}
type Pubcomp struct {
	ID ID
}
func NewPubcomp() *Pubcomp {
	return &Pubcomp{}
}
func (p *Pubcomp) Type() Type {
	return PUBCOMP
}
func (p *Pubcomp) Len() int {
	return identifiedLen()
}