diff options
| author | mat <github@matdoes.dev> | 2021-12-09 22:10:45 +0000 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2021-12-09 22:10:45 +0000 |
| commit | 966471f740ea7cb19e7106000a9f3cf9d306fd32 (patch) | |
| tree | 7bec45bf72900ad6a1752ec9f7c172f385736880 /minecraft-protocol/src/packets/mod.rs | |
| parent | ecee5e96ca2f7d00dd14f44ff0c1facd01550b65 (diff) | |
| download | azalea-drasl-966471f740ea7cb19e7106000a9f3cf9d306fd32.tar.xz | |
split mstuff
Diffstat (limited to 'minecraft-protocol/src/packets/mod.rs')
| -rw-r--r-- | minecraft-protocol/src/packets/mod.rs | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/minecraft-protocol/src/packets/mod.rs b/minecraft-protocol/src/packets/mod.rs index 8d943be0..5fb34743 100644 --- a/minecraft-protocol/src/packets/mod.rs +++ b/minecraft-protocol/src/packets/mod.rs @@ -1,21 +1,39 @@ -mod client_intention_packet; -pub use client_intention_packet::ClientIntentionPacket; -mod serverbound_status_request_packet; -pub use serverbound_status_request_packet::ServerboundStatusRequestPacket; +mod game; +mod handshake; +mod login; +mod status; + +use async_trait::async_trait; use tokio::io::AsyncRead; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ConnectionProtocol { - Handshaking = -1, - Play = 0, + Handshake = -1, + Game = 0, Status = 1, Login = 2, } -pub trait Packet { - /// Get the id of the packet, this is always a byte. - fn get_id(&self) -> u32; +pub enum Packet<'a> { + // game + // handshake + ClientIntentionPacket(&'a handshake::client_intention_packet::ClientIntentionPacket<'a>), + // login + // status + ServerboundStatusRequestPacket( + &'a status::serverbound_status_request_packet::ServerboundStatusRequestPacket, + ), + ClientboundStatusRequestPacket( + &'a status::clientbound_status_response_packet::ClientboundStatusRequestPacket, + ), +} +pub trait PacketTrait { + /// Return a version of the packet that you can actually use for stuff + fn get(&self) -> Packet; fn write(&self, buf: &mut Vec<u8>) -> (); - fn parse<T: AsyncRead + std::marker::Unpin>(&self, buf: T) -> (); + fn parse<T: AsyncRead + std::marker::Unpin>( + buf: &mut T, + // is using a static lifetime here a good idea? idk + ) -> Result<Packet<'_>, String>; } |
