Source code for eolib.protocol.net.packet

from abc import ABC, abstractmethod

from eolib.data.eo_writer import EoWriter
from eolib.protocol.net.packet_family import PacketFamily
from eolib.protocol.net.packet_action import PacketAction


[docs] class Packet(ABC): """ Object representation of a packet in the EO network protocol. """
[docs] @staticmethod @abstractmethod def family() -> PacketFamily: """ Returns the packet family associated with this packet. Returns: The packet family associated with this packet. """ raise NotImplementedError()
[docs] @staticmethod @abstractmethod def action() -> PacketAction: """ Returns the packet action associated with this packet. Returns: The packet action associated with this packet. """ raise NotImplementedError()
[docs] @abstractmethod def write(self, writer: EoWriter) -> None: """ Serializes and writes this packet to the provided EoWriter. Args: writer (EoWriter): the writer that this packet will be written to. """ raise NotImplementedError()