aboutsummaryrefslogtreecommitdiff
path: root/src/result.rs
diff options
context:
space:
mode:
authorIgor Tolmachov <me@igorek.dev>2023-08-30 23:33:11 +0900
committerIgor Tolmachev <me@igorek.dev>2024-06-23 15:34:33 +0900
commitb8c83ab5c133dc1330aa425a012d45f3c62e7ef1 (patch)
treee25f07a28b09ba5ae3d6c435a9be63fc59105800 /src/result.rs
parentf02a44964a2fdb91d62dee9c55f6d03648f985cb (diff)
downloadarchivator-b8c83ab5c133dc1330aa425a012d45f3c62e7ef1.tar.gz
archivator-b8c83ab5c133dc1330aa425a012d45f3c62e7ef1.zip
Add zip archive datatypes
Diffstat (limited to 'src/result.rs')
-rw-r--r--src/result.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/result.rs b/src/result.rs
index 47302ae..715f10c 100644
--- a/src/result.rs
+++ b/src/result.rs
@@ -7,6 +7,7 @@ pub type ArchiveResult<R> = Result<R, ArchiveError>;
7#[derive(Debug)] 7#[derive(Debug)]
8pub enum ArchiveError { 8pub enum ArchiveError {
9 IO(io::Error), 9 IO(io::Error),
10 WrongSignature { expected: u32, received: u32 },
10} 11}
11 12
12impl From<io::Error> for ArchiveError { 13impl From<io::Error> for ArchiveError {
@@ -19,6 +20,12 @@ impl Display for ArchiveError {
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20 match self { 21 match self {
21 Self::IO(err) => write!(f, "{err}"), 22 Self::IO(err) => write!(f, "{err}"),
23 Self::WrongSignature { expected, received } => {
24 write!(
25 f,
26 "Wrong signature. Expected: {expected}, received: {received}"
27 )
28 }
22 } 29 }
23 } 30 }
24} 31}
@@ -27,6 +34,7 @@ impl Error for ArchiveError {
27 fn source(&self) -> Option<&(dyn Error + 'static)> { 34 fn source(&self) -> Option<&(dyn Error + 'static)> {
28 match self { 35 match self {
29 Self::IO(source) => Some(source), 36 Self::IO(source) => Some(source),
37 _ => None,
30 } 38 }
31 } 39 }
32} 40}