From afb8ab448949eb19e09e1bdb4b263dc487a9be21 Mon Sep 17 00:00:00 2001 From: Igor Tolmachev Date: Fri, 21 Jun 2024 02:11:16 +0900 Subject: Implement deserialize Remove bincode crate and replace it by own written serializer --- src/structs/error.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/structs/error.rs') diff --git a/src/structs/error.rs b/src/structs/error.rs index b9d765d..f08c9a3 100644 --- a/src/structs/error.rs +++ b/src/structs/error.rs @@ -6,7 +6,9 @@ pub type StructResult = ArchiveResult; #[derive(Debug)] pub enum StructError { - IncorrectEnumVariant, + SerializationNotSupported { type_name: &'static str }, + DeserializationNotSupported { type_name: &'static str }, + UnexpectedEOF, } impl From for ArchiveError { @@ -21,7 +23,13 @@ impl From for ArchiveError { impl Display for StructError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - StructError::IncorrectEnumVariant => write!(f, "Can't cast enum variant type"), + StructError::SerializationNotSupported { type_name } => { + writeln!(f, "Serialization for type '{type_name}' not supported") + } + StructError::DeserializationNotSupported { type_name } => { + writeln!(f, "Deserialization for type '{type_name}' not supported") + } + StructError::UnexpectedEOF => writeln!(f, "Unexpected EOF"), } } } -- cgit v1.2.3