aboutsummaryrefslogtreecommitdiff
path: root/src/structs/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/structs/error.rs')
-rw-r--r--src/structs/error.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/structs/error.rs b/src/structs/error.rs
new file mode 100644
index 0000000..b9d765d
--- /dev/null
+++ b/src/structs/error.rs
@@ -0,0 +1,29 @@
1use crate::{ArchiveError, ArchiveResult};
2use std::error::Error;
3use std::fmt::Display;
4
5pub type StructResult<T> = ArchiveResult<T, StructError>;
6
7#[derive(Debug)]
8pub enum StructError {
9 IncorrectEnumVariant,
10}
11
12impl From<StructError> for ArchiveError<StructError> {
13 fn from(value: StructError) -> Self {
14 Self::Archivator {
15 module: "Struct serializer".to_string(),
16 error: value,
17 }
18 }
19}
20
21impl Display for StructError {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 match self {
24 StructError::IncorrectEnumVariant => write!(f, "Can't cast enum variant type"),
25 }
26 }
27}
28
29impl Error for StructError {}