use crate::{ArchiveError, ArchiveResult}; use std::error::Error; use std::fmt::Display; pub type StructResult = ArchiveResult; #[derive(Debug)] pub enum StructError { SerializationNotSupported { type_name: &'static str }, DeserializationNotSupported { type_name: &'static str }, UnexpectedEOF, } impl From for ArchiveError { fn from(value: StructError) -> Self { Self::Archivator { module: "Struct serializer".to_string(), error: value, } } } impl Display for StructError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { 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"), } } } impl Error for StructError {}