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
|
use crate::{ArchiveError, ArchiveResult};
use std::error::Error;
use std::fmt::Display;
pub type ZipResult<T> = ArchiveResult<T, ZipError>;
#[derive(Debug)]
pub enum ZipError {
EOCDRNotFound,
InvalidEOCDR,
InvalidArchiveComment,
InvalidEOCDR64Locator,
InvalidEOCDR64Signature,
InvalidEOCDR64,
InvalidCDRSignature,
InvalidCDR,
InvalidFileName,
InvalidFileComment,
}
impl From<ZipError> for ArchiveError<ZipError> {
fn from(value: ZipError) -> Self {
Self::Archivator {
module: "Zip".to_string(),
error: value,
}
}
}
impl Display for ZipError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ZipError::EOCDRNotFound => write!(f, "End of central directory record not found"),
ZipError::InvalidEOCDR => write!(f, "Invalid end of central directory record"),
ZipError::InvalidArchiveComment => write!(f, "Invalid archive comment"),
ZipError::InvalidEOCDR64Locator => {
write!(f, "Invalid zip64 end of central directory locator")
}
ZipError::InvalidEOCDR64Signature => {
write!(
f,
"Invalid signature of zip64 end of central directory record"
)
}
ZipError::InvalidEOCDR64 => write!(f, "Invalid zip64 end of central directory record"),
ZipError::InvalidCDRSignature => {
write!(f, "Invalid signature of central directory record")
}
ZipError::InvalidCDR => write!(f, "Invalid central directory record"),
ZipError::InvalidFileName => write!(f, "Invalid file name"),
ZipError::InvalidFileComment => write!(f, "Invalid file comment"),
}
}
}
impl Error for ZipError {}
|