pub mod game; pub mod handshake; pub mod login; pub mod status; use async_trait::async_trait; use crate::connect::PacketFlow; pub const PROTOCOL_VERSION: u32 = 757; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ConnectionProtocol { Handshake = -1, Game = 0, Status = 1, Login = 2, } #[derive(Clone, Debug)] pub enum Packet { Game(game::GamePacket), Handshake(handshake::HandshakePacket), Login(login::LoginPacket), Status(Box), } /// An enum of packets for a certain protocol #[async_trait] pub trait ProtocolPacket where Self: Sized, { fn id(&self) -> u32; /// Read a packet by its id, ConnectionProtocol, and flow async fn read( id: u32, flow: &PacketFlow, buf: &mut T, ) -> Result where Self: Sized; fn write(&self, buf: &mut Vec); }