aboutsummaryrefslogtreecommitdiff
path: root/src/structs/error.rs
diff options
context:
space:
mode:
authorIgor Tolmachev <me@igorek.dev>2024-06-16 21:36:13 +0900
committerIgor Tolmachev <me@igorek.dev>2024-06-23 15:34:34 +0900
commitd6055b5ac4f3ff5016bc4881cf1cc109a22c40ba (patch)
tree40a9044f923945e6effc13c627261630dddc574c /src/structs/error.rs
parent6444bee8f3e188be014841ea8cd7cfb53eb03ed9 (diff)
downloadarchivator-d6055b5ac4f3ff5016bc4881cf1cc109a22c40ba.tar.gz
archivator-d6055b5ac4f3ff5016bc4881cf1cc109a22c40ba.zip
Implement serialize
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 {}