From 0d6e4179e6cc16594a4be3ecd62d89411115f319 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 14 Dec 2021 23:03:26 -0600 Subject: progress, ? --- minecraft-protocol/src/packets/mod.rs | 42 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'minecraft-protocol/src/packets/mod.rs') diff --git a/minecraft-protocol/src/packets/mod.rs b/minecraft-protocol/src/packets/mod.rs index 46caf02b..d55bd364 100644 --- a/minecraft-protocol/src/packets/mod.rs +++ b/minecraft-protocol/src/packets/mod.rs @@ -26,21 +26,20 @@ pub enum Packet { Status(status::StatusPacket), } +/// An enum of packets for a certain protocol #[async_trait] -pub trait ProtocolPacket { - fn get_inner(&self) -> &P; - +pub trait ProtocolPacket +where + Self: Sized, +{ fn id(&self) -> u32; /// Read a packet by its id, ConnectionProtocol, and flow - async fn read< - T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send, - P: ProtocolPacket, - >( + async fn read( id: u32, flow: &PacketFlow, buf: &mut BufReader, - ) -> Result + ) -> Result where Self: Sized; @@ -129,14 +128,19 @@ pub trait ProtocolPacket { // } // } -#[async_trait] -pub trait PacketTrait { - /// Return a version of the packet that you can actually use for stuff - fn get(self) -> P; - fn write(&self, buf: &mut Vec); - async fn read( - buf: &mut BufReader, - ) -> Result - where - Self: Sized; -} +// #[async_trait] +// pub trait PacketTrait +// where +// Self: Sized, +// { +// /// Return a version of the packet that you can actually use for stuff +// fn get(self) -> dyn ProtocolPacket; + +// fn write(&self, buf: &mut Vec); + +// async fn read( +// buf: &mut BufReader, +// ) -> Result +// where +// Self: Sized; +// } -- cgit v1.2.3