From bd77f62e99a5300dfa52aef3a7040414b28ebfd6 Mon Sep 17 00:00:00 2001 From: Igor Tolmachev Date: Mon, 10 Jun 2024 23:38:08 +0900 Subject: Reset branch --- src/result.rs | 63 ----------------------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 src/result.rs (limited to 'src/result.rs') diff --git a/src/result.rs b/src/result.rs deleted file mode 100644 index 9f35920..0000000 --- a/src/result.rs +++ /dev/null @@ -1,63 +0,0 @@ -use std::error::Error; -use std::fmt::{Debug, Display}; -use std::io; - -pub type ArchiveResult = Result; - -#[derive(Debug)] -pub enum ArchiveError { - IO(io::Error), - BadArchive { reason: &'static str }, - IncorrectSignature { expected: u32, received: u32 }, - IncorrectString { location: &'static str }, - IncorrectDate { year: u16, month: u16, day: u16 }, - IncorrectTime { hour: u16, min: u16, sec: u16 }, - UnsupportedCompressionMethod { method: u16 }, -} - -impl From for ArchiveError { - fn from(value: io::Error) -> Self { - Self::IO(value) - } -} - -impl Display for ArchiveError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::IO(err) => write!(f, "{err}"), - Self::BadArchive { reason } => { - write!(f, "Bad archive because {reason}") - } - Self::IncorrectSignature { expected, received } => { - write!( - f, - "Wrong signature (expected: {expected}, received: {received})" - ) - } - Self::IncorrectString { location } => { - write!(f, "Incorrect string in {location}") - } - Self::IncorrectDate { year, month, day } => { - write!( - f, - "Incorrect date (year: {year}, month: {month}, day: {day})" - ) - } - Self::IncorrectTime { hour, min, sec } => { - write!(f, "Incorrect time (hour: {hour}, min: {min}, sec: {sec})") - } - Self::UnsupportedCompressionMethod { method } => { - write!(f, "Unsupported compression method (method: {method})") - } - } - } -} - -impl Error for ArchiveError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match self { - Self::IO(source) => Some(source), - _ => None, - } - } -} -- cgit v1.2.3