/// Handles a packet, returning `Err` if the player
/// should be disconnected.
Handles a packet, returning `Err` if the player
should be disconnected.
Handles a packet returning ` Err ` if the player should be disconnected .
async fn _handle_packet(ih: &mut InitialHandler, packet: Box<dyn Packet>) -> Result<(), Error> {
    // Find packet type and forward to correct function
    match packet.ty() {
        PacketType::Handshake => handle_handshake(ih, cast_packet::<Handshake>(&*packet))?,
        PacketType::Request => handle_request(ih, cast_packet::<Request>(&*packet))?,
        PacketType::Ping => handle_ping(ih, cast_packet::<Ping>(&*packet))?,
        PacketType::LoginStart => handle_login_start(ih, cast_packet::<LoginStart>(&*packet))?,
        PacketType::EncryptionResponse => {
            handle_encryption_response(ih, cast_packet::<EncryptionResponse>(&*packet)).await?
        }
        ty => return Err(Error::InvalidPacket(ty, ih.stage)),
    }
    Ok(())
}
async fn _handle_packet ( ih : & mut InitialHandler , packet : Box < dyn Packet > ) -> Result < ( ) , Error > { // Find packet type and forward to correct function match packet . ty ( ) { PacketType :: Handshake => handle_handshake ( ih , cast_packet :: < Handshake > ( & * packet ) ) ? , PacketType :: Request => handle_request ( ih , cast_packet :: < Request > ( & * packet ) ) ? , PacketType :: Ping => handle_ping ( ih , cast_packet :: < Ping > ( & * packet ) ) ? , PacketType :: LoginStart => handle_login_start ( ih , cast_packet :: < LoginStart > ( & * packet ) ) ? , PacketType :: EncryptionResponse => { handle_encryption_response ( ih , cast_packet :: < EncryptionResponse > ( & * packet ) ) . await ? } ty => return Err ( Error :: InvalidPacket ( ty , ih . stage ) ) , } Ok ( ( ) ) }
Handles a packet, returning `Err` if the player
should be disconnected.
Handles a packet returning ` Err ` if the player should be disconnected .
ih
&mut InitialHandler
packet
Box<dyn Packet>