Trait Packet

Source
pub trait Packet {
    // Required methods
    fn version(&self) -> u8;
    fn payload(&self) -> &[u8];
    fn read_from<R: Read>(reader: &mut R) -> Result<Self, IpcError>
       where Self: Sized;
    fn serialize(&self) -> Vec<u8>;
}
Expand description

The Packet trait defines the interface for handling packets in an IPC context. Types implementing this trait can be used to represent and manipulate packets.

§Required Methods

  • version - This method returns the version of the packet.
  • payload - This method returns a reference to the payload of the packet.
  • read_from - This method reads a packet from a reader and returns an instance of the implementing type.
  • serialize - This method serializes the packet into a vector of bytes.

Required Methods§

Source

fn version(&self) -> u8

Source

fn payload(&self) -> &[u8]

Source

fn read_from<R: Read>(reader: &mut R) -> Result<Self, IpcError>
where Self: Sized,

Source

fn serialize(&self) -> Vec<u8>

Implementors§