pub trait Packet: Sized {
fn deserialize<R: Read>(r: &mut R, state: &ClientState) -> Result<Self>;
fn get_packet_name(&self) -> &str;
fn get_clientstate(&self) -> ClientState;
fn get_id(&self) -> i32;
fn to_u8(&self) -> Result<Vec<u8>>;
}
Expand description
Trait for the two enums ClientboundPacket and ServerboundPacket
Required Methods§
sourcefn deserialize<R: Read>(r: &mut R, state: &ClientState) -> Result<Self>
fn deserialize<R: Read>(r: &mut R, state: &ClientState) -> Result<Self>
Deserializes a Read type into a packet. You usually won’t need to use this.
sourcefn get_packet_name(&self) -> &str
fn get_packet_name(&self) -> &str
Returns the packet’s name
sourcefn get_clientstate(&self) -> ClientState
fn get_clientstate(&self) -> ClientState
Returns the connection state in which the packet can be sent