aboutsummaryrefslogtreecommitdiff
path: root/minecraft-protocol/src/packets
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-15 13:43:57 -0600
committermat <github@matdoes.dev>2021-12-15 13:43:57 -0600
commit732de94d7b9f1bf2bc9239c8138a37c53242b470 (patch)
treeeaeaddbf73bf5379fbb1924e57a28b8dad5be48b /minecraft-protocol/src/packets
parentace140500734d33fe53126086a8d9278fa861e21 (diff)
downloadazalea-drasl-732de94d7b9f1bf2bc9239c8138a37c53242b470.tar.xz
oh yeah it compiles
Diffstat (limited to 'minecraft-protocol/src/packets')
-rw-r--r--minecraft-protocol/src/packets/game/mod.rs41
-rw-r--r--minecraft-protocol/src/packets/handshake/mod.rs2
2 files changed, 40 insertions, 3 deletions
diff --git a/minecraft-protocol/src/packets/game/mod.rs b/minecraft-protocol/src/packets/game/mod.rs
index 08444697..06d8ae4c 100644
--- a/minecraft-protocol/src/packets/game/mod.rs
+++ b/minecraft-protocol/src/packets/game/mod.rs
@@ -1,2 +1,41 @@
+use async_trait::async_trait;
+use tokio::io::BufReader;
+
+use crate::connect::PacketFlow;
+
+use super::ProtocolPacket;
+
#[derive(Clone, Debug)]
-pub enum GamePacket {}
+pub enum GamePacket
+where
+ Self: Sized, {}
+
+#[async_trait]
+impl ProtocolPacket for GamePacket {
+ fn id(&self) -> u32 {
+ match self {
+ _ => 0x00,
+ }
+ }
+
+ fn write(&self, buf: &mut Vec<u8>) {
+ match self {
+ _ => (),
+ }
+ }
+
+ /// Read a packet by its id, ConnectionProtocol, and flow
+ async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
+ id: u32,
+ flow: &PacketFlow,
+ buf: &mut BufReader<T>,
+ ) -> Result<GamePacket, String>
+ where
+ Self: Sized,
+ {
+ match flow {
+ PacketFlow::ServerToClient => Err("HandshakePacket::read not implemented".to_string()),
+ PacketFlow::ClientToServer => Err("HandshakePacket::read not implemented".to_string()),
+ }
+ }
+}
diff --git a/minecraft-protocol/src/packets/handshake/mod.rs b/minecraft-protocol/src/packets/handshake/mod.rs
index 792588b5..01010e1e 100644
--- a/minecraft-protocol/src/packets/handshake/mod.rs
+++ b/minecraft-protocol/src/packets/handshake/mod.rs
@@ -1,7 +1,5 @@
pub mod client_intention_packet;
-use std::f32::consts::E;
-
use async_trait::async_trait;
use tokio::io::BufReader;