M2-PT-DRP/source/packets/base/BasePacket.py

19 lines
448 B
Python

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
"""