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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("Could not open file: {0}")]
Open(#[from] std::io::Error),
#[error("Error parsing header: {0}")]
HeaderError(#[from] HeaderError),
#[error("Error parsing string data: {0}")]
StringDataError(#[from] StringDataError),
#[error("Error parsing link target id list: {0}")]
LinkTargetIdListError(#[from] LinkTargetIdListError),
#[error("Error parsing link info: {0}")]
LinkInfoError(#[from] LinkInfoError),
#[error("Error parsing extra data: {0}")]
ExtraDataError(#[from] ExtraDataError),
}
#[derive(Debug, Error)]
pub enum HeaderError {
#[error("could not read header: {0}")]
Read(#[from] std::io::Error),
}
#[derive(Debug, Error)]
pub enum LinkTargetIdListError {
#[error("could not read link target id list data: {0}")]
Read(#[from] std::io::Error),
}
#[derive(Debug, Error)]
pub enum LinkInfoError {
#[error("could not read link info data: {0}")]
Read(#[from] std::io::Error),
#[error("could not convert data to string: {0}")]
StringConversion(std::string::FromUtf8Error),
#[error("could not convert data to wide string: {0}")]
WideStringConversion(std::string::FromUtf16Error),
}
#[derive(Debug, Error)]
pub enum StringDataError {
#[error("could not read string data: {0}")]
Read(#[from] std::io::Error),
#[error("string conversion failed: {0}")]
WideStringConversion(#[from] std::string::FromUtf16Error),
#[error("string conversion failed: {0}")]
StringConversion(#[from] std::string::FromUtf8Error),
#[error("string conversion failed: {0}")]
WideStringRead(#[from] widestring::MissingNulError<u16>),
}
#[derive(Debug, Error)]
pub enum ExtraDataError {
#[error("could not read extra data: {0}")]
Read(#[from] std::io::Error),
#[error("unknown extra block: size: 0x{0:08x}, signature: 0x{1:08x}")]
UnknownBlock(u32, u32),
#[error("error converting unicode string: {0}")]
WideStringConversion(#[from] std::string::FromUtf16Error),
#[error("missing string data")]
MissingStringData,
}