pub trait ProtocolPacketwhere
Self: Sized,{
// Required methods
fn id(&self) -> u32;
fn read(
id: u32,
buf: &mut Cursor<&[u8]>,
) -> Result<Self, Box<ReadPacketError>>;
fn write(&self, buf: &mut impl Write) -> Result<(), Error>;
}
Expand description
An enum of packets for a certain protocol
Required Methods§
fn id(&self) -> u32
Sourcefn read(id: u32, buf: &mut Cursor<&[u8]>) -> Result<Self, Box<ReadPacketError>>
fn read(id: u32, buf: &mut Cursor<&[u8]>) -> Result<Self, Box<ReadPacketError>>
Read a packet by its id, ConnectionProtocol
, and flow
fn write(&self, buf: &mut impl Write) -> Result<(), Error>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.