aboutsummaryrefslogtreecommitdiff
path: root/src/result.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/result.rs')
-rw-r--r--src/result.rs29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/result.rs b/src/result.rs
index 715f10c..9f35920 100644
--- a/src/result.rs
+++ b/src/result.rs
@@ -7,7 +7,12 @@ 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 BadArchive { reason: &'static str },
11 IncorrectSignature { expected: u32, received: u32 },
12 IncorrectString { location: &'static str },
13 IncorrectDate { year: u16, month: u16, day: u16 },
14 IncorrectTime { hour: u16, min: u16, sec: u16 },
15 UnsupportedCompressionMethod { method: u16 },
11} 16}
12 17
13impl From<io::Error> for ArchiveError { 18impl From<io::Error> for ArchiveError {
@@ -20,12 +25,30 @@ impl Display for ArchiveError {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 match self { 26 match self {
22 Self::IO(err) => write!(f, "{err}"), 27 Self::IO(err) => write!(f, "{err}"),
23 Self::WrongSignature { expected, received } => { 28 Self::BadArchive { reason } => {
29 write!(f, "Bad archive because {reason}")
30 }
31 Self::IncorrectSignature { expected, received } => {
32 write!(
33 f,
34 "Wrong signature (expected: {expected}, received: {received})"
35 )
36 }
37 Self::IncorrectString { location } => {
38 write!(f, "Incorrect string in {location}")
39 }
40 Self::IncorrectDate { year, month, day } => {
24 write!( 41 write!(
25 f, 42 f,
26 "Wrong signature. Expected: {expected}, received: {received}" 43 "Incorrect date (year: {year}, month: {month}, day: {day})"
27 ) 44 )
28 } 45 }
46 Self::IncorrectTime { hour, min, sec } => {
47 write!(f, "Incorrect time (hour: {hour}, min: {min}, sec: {sec})")
48 }
49 Self::UnsupportedCompressionMethod { method } => {
50 write!(f, "Unsupported compression method (method: {method})")
51 }
29 } 52 }
30 } 53 }
31} 54}