aboutsummaryrefslogtreecommitdiff
path: root/src/result.rs
diff options
context:
space:
mode:
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}