use std::io;
use std::string::FromUtf8Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("I/O error: {0}")]
Io(io::Error),
#[error("Invalid PF8 format: {0}")]
InvalidFormat(String),
#[error("File not found in archive: {0}")]
FileNotFound(String),
#[error("Invalid UTF-8 in file name: {0}")]
InvalidUtf8(FromUtf8Error),
#[error("Encryption/decryption error: {0}")]
Crypto(String),
#[error("Archive is corrupted: {0}")]
Corrupted(String),
#[error("Operation was cancelled")]
Cancelled,
}
impl From<io::Error> for Error {
fn from(err: io::Error) -> Self {
Error::Io(err)
}
}
impl From<FromUtf8Error> for Error {
fn from(err: FromUtf8Error) -> Self {
Error::InvalidUtf8(err)
}
}
impl From<walkdir::Error> for Error {
fn from(err: walkdir::Error) -> Self {
Error::Io(err.into())
}
}