blob: f07163ca8f84d38a28c6d7d6e94d51756f52e6a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
use crate::{ArchiveError, ArchiveResult};
use std::error::Error;
use std::fmt::Display;
pub type StructResult<T> = ArchiveResult<T, StructError>;
#[derive(Debug)]
pub enum StructError {
SerializationNotSupported { type_name: &'static str },
DeserializationNotSupported { type_name: &'static str },
UnexpectedEOF,
}
impl From<StructError> for ArchiveError<StructError> {
fn from(value: StructError) -> Self {
Self::Archivator {
module: "Struct serializer",
error: value,
}
}
}
impl Display for StructError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::SerializationNotSupported { type_name } => {
writeln!(f, "Serialization for type '{type_name}' not supported")
}
Self::DeserializationNotSupported { type_name } => {
writeln!(f, "Deserialization for type '{type_name}' not supported")
}
Self::UnexpectedEOF => writeln!(f, "Unexpected EOF"),
}
}
}
impl Error for StructError {}
|