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§
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>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".