From d8be93a740e8cc8103c4f9e260a62244eba1a6a4 Mon Sep 17 00:00:00 2001 From: Igor Tolmachov Date: Thu, 17 Aug 2023 15:34:47 +0900 Subject: Add basic lib architecture --- src/result.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/result.rs (limited to 'src/result.rs') diff --git a/src/result.rs b/src/result.rs new file mode 100644 index 0000000..47302ae --- /dev/null +++ b/src/result.rs @@ -0,0 +1,32 @@ +use std::error::Error; +use std::fmt::{Debug, Display}; +use std::io; + +pub type ArchiveResult = Result; + +#[derive(Debug)] +pub enum ArchiveError { + IO(io::Error), +} + +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}"), + } + } +} + +impl Error for ArchiveError { + fn source(&self) -> Option<&(dyn Error + 'static)> { + match self { + Self::IO(source) => Some(source), + } + } +} -- cgit v1.2.3