aboutsummaryrefslogtreecommitdiff
path: root/src/result.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/result.rs')
-rw-r--r--src/result.rs32
1 files changed, 32 insertions, 0 deletions
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 @@
1use std::error::Error;
2use std::fmt::{Debug, Display};
3use std::io;
4
5pub type ArchiveResult<R> = Result<R, ArchiveError>;
6
7#[derive(Debug)]
8pub enum ArchiveError {
9 IO(io::Error),
10}
11
12impl From<io::Error> for ArchiveError {
13 fn from(value: io::Error) -> Self {
14 Self::IO(value)
15 }
16}
17
18impl Display for ArchiveError {
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20 match self {
21 Self::IO(err) => write!(f, "{err}"),
22 }
23 }
24}
25
26impl Error for ArchiveError {
27 fn source(&self) -> Option<&(dyn Error + 'static)> {
28 match self {
29 Self::IO(source) => Some(source),
30 }
31 }
32}