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 - } -}