pub mod client_intention_packet; use async_trait::async_trait; use crate::connect::PacketFlow; use super::ProtocolPacket; #[derive(Clone, Debug)] pub enum HandshakePacket where Self: Sized, { ClientIntentionPacket(client_intention_packet::ClientIntentionPacket), } #[async_trait] impl ProtocolPacket for HandshakePacket { fn id(&self) -> u32 { match self { HandshakePacket::ClientIntentionPacket(_packet) => 0x00, } } fn write(&self, buf: &mut Vec) -> Result<(), std::io::Error> { match self { HandshakePacket::ClientIntentionPacket(packet) => packet.write(buf), } } /// Read a packet by its id, ConnectionProtocol, and flow async fn read( id: u32, flow: &PacketFlow, buf: &mut T, ) -> Result where Self: Sized, { match flow { PacketFlow::ServerToClient => Err("HandshakePacket::read not implemented".to_string()), PacketFlow::ClientToServer => match id { 0x00 => Ok(client_intention_packet::ClientIntentionPacket::read(buf).await?), _ => Err(format!("Unknown ClientToServer status packet id: {}", id)), }, } } }