diff options
| author | Igor Tolmachev <me@igorek.dev> | 2024-06-21 02:11:16 +0900 |
|---|---|---|
| committer | Igor Tolmachev <me@igorek.dev> | 2024-06-23 15:34:35 +0900 |
| commit | afb8ab448949eb19e09e1bdb4b263dc487a9be21 (patch) | |
| tree | 5806bc9bc566dcda64818917a222c313dde3cb55 /src/structs/error.rs | |
| parent | d6055b5ac4f3ff5016bc4881cf1cc109a22c40ba (diff) | |
| download | archivator-afb8ab448949eb19e09e1bdb4b263dc487a9be21.tar.gz archivator-afb8ab448949eb19e09e1bdb4b263dc487a9be21.zip | |
Implement deserialize
Remove bincode crate and replace it by own written serializer
Diffstat (limited to 'src/structs/error.rs')
| -rw-r--r-- | src/structs/error.rs | 12 |
1 files changed, 10 insertions, 2 deletions
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<T> = ArchiveResult<T, StructError>; | |||
| 6 | 6 | ||
| 7 | #[derive(Debug)] | 7 | #[derive(Debug)] |
| 8 | pub enum StructError { | 8 | pub enum StructError { |
| 9 | IncorrectEnumVariant, | 9 | SerializationNotSupported { type_name: &'static str }, |
| 10 | DeserializationNotSupported { type_name: &'static str }, | ||
| 11 | UnexpectedEOF, | ||
| 10 | } | 12 | } |
| 11 | 13 | ||
| 12 | impl From<StructError> for ArchiveError<StructError> { | 14 | impl From<StructError> for ArchiveError<StructError> { |
| @@ -21,7 +23,13 @@ impl From<StructError> for ArchiveError<StructError> { | |||
| 21 | impl Display for StructError { | 23 | impl Display for StructError { |
| 22 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 24 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 23 | match self { | 25 | match self { |
| 24 | StructError::IncorrectEnumVariant => write!(f, "Can't cast enum variant type"), | 26 | StructError::SerializationNotSupported { type_name } => { |
| 27 | writeln!(f, "Serialization for type '{type_name}' not supported") | ||
| 28 | } | ||
| 29 | StructError::DeserializationNotSupported { type_name } => { | ||
| 30 | writeln!(f, "Deserialization for type '{type_name}' not supported") | ||
| 31 | } | ||
| 32 | StructError::UnexpectedEOF => writeln!(f, "Unexpected EOF"), | ||
| 25 | } | 33 | } |
| 26 | } | 34 | } |
| 27 | } | 35 | } |
