aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/mod.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-16 23:33:06 -0600
committermat <github@matdoes.dev>2021-12-16 23:33:06 -0600
commitc4eecaf13a4f8f0a81dc278078727df23caa8411 (patch)
tree5082f54d1a9242281d80c250e587235a3ac3755b /azalea-protocol/src/packets/mod.rs
parent1dc56b6f519f386b6e0b5eac47a84576cedbbb33 (diff)
downloadazalea-drasl-c4eecaf13a4f8f0a81dc278078727df23caa8411.tar.xz
try to implement compression
Diffstat (limited to 'azalea-protocol/src/packets/mod.rs')
-rw-r--r--azalea-protocol/src/packets/mod.rs101
1 files changed, 1 insertions, 100 deletions
diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs
index a074b570..08c94509 100644
--- a/azalea-protocol/src/packets/mod.rs
+++ b/azalea-protocol/src/packets/mod.rs
@@ -38,109 +38,10 @@ where
async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
id: u32,
flow: &PacketFlow,
- buf: &mut BufReader<T>,
+ buf: &mut T,
) -> Result<Self, String>
where
Self: Sized;
fn write(&self, buf: &mut Vec<u8>);
}
-
-// impl Packet {
-// fn get_inner_packet(&self) -> &dyn PacketTrait {
-// match self {
-// Packet::ClientIntentionPacket(packet) => packet,
-// Packet::ServerboundStatusRequestPacket(packet) => packet,
-// Packet::ClientboundStatusResponsePacket(packet) => packet,
-// Packet::ServerboundHelloPacket(packet) => packet,
-// Packet::ClientboundHelloPacket(packet) => packet,
-// }
-// }
-
-// pub fn id(&self) -> u32 {
-// match self {
-// Packet::ClientIntentionPacket(_packet) => 0x00,
-// Packet::ServerboundStatusRequestPacket(_packet) => 0x00,
-// Packet::ClientboundStatusResponsePacket(_packet) => 0x00,
-// Packet::ServerboundHelloPacket(_packet) => 0x00,
-// Packet::ClientboundHelloPacket(_packet) => 0x01,
-// }
-// }
-
-// /// Read a packet by its id, ConnectionProtocol, and flow
-// pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
-// id: u32,
-// protocol: &ConnectionProtocol,
-// flow: &PacketFlow,
-// buf: &mut BufReader<T>,
-// ) -> Result<Packet, String> {
-// match protocol {
-// ConnectionProtocol::Handshake => match flow {
-// PacketFlow::ClientToServer => match id {
-// 0x00 => Ok(
-// handshake::client_intention_packet::ClientIntentionPacket::read(buf).await?,
-// ),
-// _ => Err(format!("Unknown ClientToServer handshake packet id: {}", id)),
-// }
-// PacketFlow::ServerToClient => Err("ServerToClient handshake packets not implemented".to_string()),
-// },
-
-// ConnectionProtocol::Game => Err("Game protocol not implemented yet".to_string()),
-
-// ConnectionProtocol::Status => match flow {
-// PacketFlow::ServerToClient => match id {
-// 0x00 => Ok(
-// status::clientbound_status_response_packet::ClientboundStatusResponsePacket
-// ::read(buf)
-// .await?,
-// ),
-// _ => Err(format!("Unknown ServerToClient status packet id: {}", id)),
-// },
-// PacketFlow::ClientToServer => match id {
-// 0x00 => Ok(
-// status::serverbound_status_request_packet::ServerboundStatusRequestPacket
-// ::read(buf)
-// .await?,
-// ),
-// _ => Err(format!("Unknown ClientToServer status packet id: {}", id)),
-// },
-// },
-
-// ConnectionProtocol::Login => match flow {
-// PacketFlow::ServerToClient => match id {
-// 0x01 => Ok(
-// login::clientbound_hello_packet::ClientboundHelloPacket::read(buf).await?,
-// ),
-// _ => Err(format!("Unknown ServerToClient login packet id: {}", id)),
-// },
-// PacketFlow::ClientToServer => match id {
-// 0x00 => Ok(
-// login::serverbound_hello_packet::ServerboundHelloPacket::read(buf).await?,
-// ),
-// _ => Err(format!("Unknown ClientToServer login packet id: {}", id)),
-// },
-// },
-// }
-// }
-
-// pub fn write(&self, buf: &mut Vec<u8>) {
-// self.get_inner_packet().write(buf);
-// }
-// }
-
-// #[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;
-// }