code: func (t Type) New() (Generic, error) {
  	switch t {
  	case CONNECT:
  		return NewConnect(), nil
  	case CONNACK:
  		return NewConnack(), nil
  	case PUBLISH:
  		return NewPublish(), nil
  	case PUBACK:
  		return NewPuback(), nil
  	case PUBREC:
  		return NewPubrec(), nil
  	case PUBREL:
  		return NewPubrel(), nil
  	case PUBCOMP:
  		return NewPubcomp(), nil
  	case SUBSCRIBE:
  		return NewSubscribe(), nil
  	case SUBACK:
  		return NewSuback(), nil
  	case UNSUBSCRIBE:
  		return NewUnsubscribe(), nil
  	case UNSUBACK:
  		return NewUnsuback(), nil
  	case PINGREQ:
  		return NewPingreq(), nil
  	case PINGRESP:
  		return NewPingresp(), nil
  	case DISCONNECT:
  		return NewDisconnect(), nil
  	}
  
  	return nil, ErrInvalidPacketType
  }
docs: // New creates a new packet based on the type. It is a shortcut to call one of
  // the New*Packet functions. An error is returned if the type is invalid.