From 48e56f52755f22da1f456619ae6a00556a93efb1 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Mon, 6 Feb 2023 20:18:16 +0100 Subject: [PATCH] undo --- kubi-udp/src/lib.rs | 1 - kubi-udp/src/serializable.rs | 22 ---------------------- 2 files changed, 23 deletions(-) delete mode 100644 kubi-udp/src/serializable.rs diff --git a/kubi-udp/src/lib.rs b/kubi-udp/src/lib.rs index 319ed4f..ec14b35 100644 --- a/kubi-udp/src/lib.rs +++ b/kubi-udp/src/lib.rs @@ -2,7 +2,6 @@ pub mod client; pub mod server; pub(crate) mod packet; pub(crate) mod common; -pub(crate) mod serializable; pub use common::ClientId; //pub(crate) trait Serializable: bincode::Encode + bincode::Decode {} diff --git a/kubi-udp/src/serializable.rs b/kubi-udp/src/serializable.rs deleted file mode 100644 index 61da4d8..0000000 --- a/kubi-udp/src/serializable.rs +++ /dev/null @@ -1,22 +0,0 @@ -use anyhow::Result; -use crate::BINCODE_CONFIG; - -pub trait Serializable: bincode::Encode + bincode::Decode { - fn serialize(&self, buf: &mut [u8]) -> Result<()>; - fn deserialize(buf: &[u8]) -> Result; - - fn serialize_to_vec(&self) -> Result> { - let mut buf = Vec::new(); - self.serialize(&mut buf)?; - Ok(buf) - } -} -impl Serializable for T { - fn serialize(&self, buf: &mut [u8]) -> Result<()> { - bincode::encode_into_slice(self, buf, BINCODE_CONFIG)?; - Ok(()) - } - fn deserialize(buf: &[u8]) -> Result { - bincode::decode_from_slice(buf, BINCODE_CONFIG)?.0 - } -}