1use std::io;
4use std::string::FromUtf8Error;
5
6pub type Result<T> = std::result::Result<T, Error>;
8
9#[derive(Debug, thiserror::Error)]
11pub enum Error {
12 #[error("I/O error: {0}")]
14 Io(io::Error),
15 #[error("Invalid PF8 format: {0}")]
17 InvalidFormat(String),
18 #[error("File not found in archive: {0}")]
20 FileNotFound(String),
21 #[error("Invalid UTF-8 in file name: {0}")]
23 InvalidUtf8(FromUtf8Error),
24 #[error("Encryption/decryption error: {0}")]
26 Crypto(String),
27 #[error("Archive is corrupted: {0}")]
29 Corrupted(String),
30 #[error("Operation was cancelled")]
32 Cancelled,
33}
34
35impl From<io::Error> for Error {
36 fn from(err: io::Error) -> Self {
37 Error::Io(err)
38 }
39}
40
41impl From<FromUtf8Error> for Error {
42 fn from(err: FromUtf8Error) -> Self {
43 Error::InvalidUtf8(err)
44 }
45}
46
47impl From<walkdir::Error> for Error {
48 fn from(err: walkdir::Error) -> Self {
49 Error::Io(err.into())
50 }
51}