1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use std;
#[derive(Debug)]
pub enum OLEError {
BadFileSize,
IOError(std::io::Error),
NotImplementedYet,
InvalidOLEFile,
BadSizeValue(&'static str),
EmptyMasterSectorAllocationTable,
NotSectorUsedBySAT,
NodeTypeUnknown,
BadRootStorageSize
}
impl std::error::Error for OLEError {
fn description(&self) -> &str {
match *self {
OLEError::BadFileSize => "Filesize is null or too big.",
OLEError::IOError(ref e) => e.description(),
OLEError::NotImplementedYet => "Method not implemented yet",
OLEError::InvalidOLEFile => "Invalid OLE File",
OLEError::BadSizeValue(ref e) => e,
OLEError::EmptyMasterSectorAllocationTable => "MSAT is empty",
OLEError::NotSectorUsedBySAT => "Sector is not a sector used by the SAT.",
OLEError::NodeTypeUnknown => "Unknown node type",
OLEError::BadRootStorageSize => "Bad RootStorage size"
}
}
fn cause(&self) -> Option<&std::error::Error> {
match *self {
OLEError::IOError(ref e) => Some(e),
_ => None
}
}
}
impl std::fmt::Display for OLEError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
use std::error::Error;
write!(f, "{}", self.description())
}
}