1use std::io;
4
5pub type Result<T> = std::result::Result<T, SZipError>;
7
8#[derive(Debug)]
10pub enum SZipError {
11 Io(io::Error),
13 InvalidFormat(String),
15 EntryNotFound(String),
17 UnsupportedCompression(u16),
19}
20
21impl std::fmt::Display for SZipError {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 match self {
24 SZipError::Io(e) => write!(f, "I/O error: {}", e),
25 SZipError::InvalidFormat(msg) => write!(f, "Invalid ZIP format: {}", msg),
26 SZipError::EntryNotFound(name) => write!(f, "Entry not found: {}", name),
27 SZipError::UnsupportedCompression(method) => {
28 write!(f, "Unsupported compression method: {}", method)
29 }
30 }
31 }
32}
33
34impl std::error::Error for SZipError {}
35
36impl From<io::Error> for SZipError {
37 fn from(err: io::Error) -> Self {
38 SZipError::Io(err)
39 }
40}