pub trait ClientPacket: WriteTo {
// Required method
fn get_id(&self, protocol: ConnectionProtocol) -> Option<i32>;
// Provided method
fn write_packet(
&self,
writer: &mut impl Write,
protocol: ConnectionProtocol,
) -> Result<(), PacketError> { ... }
}Expand description
A trait for packets sent from the client to the server.
Required Methods§
Sourcefn get_id(&self, protocol: ConnectionProtocol) -> Option<i32>
fn get_id(&self, protocol: ConnectionProtocol) -> Option<i32>
Gets the ID of the packet for the given protocol.
Provided Methods§
Sourcefn write_packet(
&self,
writer: &mut impl Write,
protocol: ConnectionProtocol,
) -> Result<(), PacketError>
fn write_packet( &self, writer: &mut impl Write, protocol: ConnectionProtocol, ) -> Result<(), PacketError>
Writes the packet to the given writer.
§Errors
- If the packet fails to write.
- If the protocol is invalid.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".