pub trait Packet: Sized {
const ID: i32;
// Required methods
fn to_bytes(&self) -> Vec<u8> ⓘ;
fn from_reader(reader: &mut PacketReader) -> Result<Self, Errors>;
}
Required Associated Constants§
Required Methods§
Sourcefn to_bytes(&self) -> Vec<u8> ⓘ
fn to_bytes(&self) -> Vec<u8> ⓘ
Serializes the packet to a Vec<u8> in accordance with the minecraft protocol so that it can be sent via the network.
§Arguments
returns: Vec<u8>
Sourcefn from_reader(reader: &mut PacketReader) -> Result<Self, Errors>
fn from_reader(reader: &mut PacketReader) -> Result<Self, Errors>
Allows the reading of packets from a PacketReader.
§Arguments
reader
: The reader the packet will be read from.
returns: Result<Self, Errors>
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.