aboutsummaryrefslogtreecommitdiff
path: root/minecraft-protocol/src/packets/mod.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-14 23:03:26 -0600
committermat <github@matdoes.dev>2021-12-14 23:03:26 -0600
commit0d6e4179e6cc16594a4be3ecd62d89411115f319 (patch)
tree019284386b7a2540efe440e0c2f3aad27801a5a6 /minecraft-protocol/src/packets/mod.rs
parentc96ae8fce4e53ea9fad111ac7f479f2fa33ef859 (diff)
downloadazalea-drasl-0d6e4179e6cc16594a4be3ecd62d89411115f319.tar.xz
progress, ?
Diffstat (limited to 'minecraft-protocol/src/packets/mod.rs')
-rw-r--r--minecraft-protocol/src/packets/mod.rs42
1 files changed, 23 insertions, 19 deletions
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<P: PacketTrait>(&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<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
id: u32,
flow: &PacketFlow,
buf: &mut BufReader<T>,
- ) -> Result<P, String>
+ ) -> Result<Self, String>
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<P: ProtocolPacket>(self) -> P;
- fn write(&self, buf: &mut Vec<u8>);
- async fn read<T: AsyncRead + std::marker::Unpin + std::marker::Send, P: ProtocolPacket>(
- buf: &mut BufReader<T>,
- ) -> Result<P, String>
- 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<u8>);
+
+// async fn read<T: AsyncRead + std::marker::Unpin + std::marker::Send, P: ProtocolPacket>(
+// buf: &mut BufReader<T>,
+// ) -> Result<P, String>
+// where
+// Self: Sized;
+// }