import abc class BasePacket(abc.ABC): @abc.abstractmethod def pack(self) -> bytes: """ Serialize the object to bytes. :return: bytes representing the object """ @classmethod @abc.abstractmethod def unpack(cls, data: bytes) -> "BasePacket": """ Deserialize the object from bytes. :param data: the data to deserialize :return: the deserialized object """