code: func (sp *Suback) Decode(src []byte) (int, error) {
  	total := 0
  
  	// decode header
  	hl, _, rl, err := headerDecode(src[total:], SUBACK)
  	total += hl
  	if err != nil {
  		return total, err
  	}
  
  	// check buffer length
  	if len(src) < total+2 {
  		return total, makeError(sp.Type(), "insufficient buffer size, expected %d, got %d", total+2, len(src))
  	}
  
  	// check remaining length
  	if rl <= 2 {
  		return total, makeError(sp.Type(), "expected remaining length to be greater than 2, got %d", rl)
  	}
  
  	// read packet id
  	sp.ID = ID(binary.BigEndian.Uint16(src[total:]))
  	total += 2
  
  	// check packet id
  	if !sp.ID.Valid() {
  		return total, makeError(sp.Type(), "packet id must be grater than zero")
  	}
  
  	// calculate number of return codes
  	rcl := int(rl) - 2
  
  	// read return codes
  	sp.ReturnCodes = make([]QOS, rcl)
  	for i, rc := range src[total : total+rcl] {
  		sp.ReturnCodes[i] = QOS(rc)
  	}
  	total += len(sp.ReturnCodes)
  
  	// validate return codes
  	for i, code := range sp.ReturnCodes {
  		if !code.Successful() && code != QOSFailure {
  			return total, makeError(sp.Type(), "invalid return code %d for topic %d", code, i)
  		}
  	}
  
  	return total, nil
  }
docs: // 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.