From 913ae5e74a914ca5225f3dd751d1a4b8bccabbf0 Mon Sep 17 00:00:00 2001 From: Raine Date: Sun, 15 Oct 2023 18:06:33 +0200 Subject: [PATCH] fix: remove old code --- domo_proto/src/packet/mod.rs | 50 +++++------------------------------- 1 file changed, 6 insertions(+), 44 deletions(-) diff --git a/domo_proto/src/packet/mod.rs b/domo_proto/src/packet/mod.rs index 651ba68..33088f0 100644 --- a/domo_proto/src/packet/mod.rs +++ b/domo_proto/src/packet/mod.rs @@ -27,50 +27,6 @@ pub struct Packet { pub data: PacketData, } -impl Packet { - /// Build packet **without** CRC32 - pub fn build_base_packet(&self) -> Vec { - match self { - Packet { - dest, - src, - packet_id, - reply_to, - command, - data, - } => { - let mut buf = Vec::new(); - let data = data.clone().into_bytes(); - let data_length = data.len(); - buf.push(0x01); - buf.extend_from_slice(&dest.bytes); - buf.extend_from_slice(&src.bytes); - buf.extend_from_slice(&packet_id.bytes); - buf.extend_from_slice(&reply_to.bytes); - buf.push(command.clone()); - buf.push((data_length >> 8) as u8); - buf.push((data_length & 0xFF) as u8); - buf.extend(data); - buf - } - } - } - - pub fn get_crc32(&self) -> u32 { - crc32fast::hash(self.build_base_packet().as_slice()) - } - - pub fn build_full_packet(&self) -> Vec { - match self { - Packet { .. } => { - let mut buf = self.build_base_packet(); - buf.extend_from_slice(crc32fast::hash(&buf.as_slice()).to_be_bytes().as_ref()); - buf - } - } - } -} - pub trait ToPacket { fn to_packet(self, src: Identifier, dest: Identifier, packet_id: Identifier, reply_to: Identifier) -> Packet; } @@ -81,4 +37,10 @@ impl TryFrom> for Packet { fn try_from(data: Vec) -> io::Result { Ok(RawPacket::try_from(data)?.into()) } +} + +impl Into> for Packet { + fn into(self) -> Vec { + RawPacket::from(self).into() + } } \ No newline at end of file