use std::io;
use std::path::PathBuf;
pub type Result<T, E = IdentifyError> = std::result::Result<T, E>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum IdentifyError {
#[error("{} does not exist.", path.display())]
PathNotFound {
path: PathBuf,
#[source]
source: io::Error,
},
#[error("IO error: {source}")]
IoError {
#[source]
source: io::Error,
},
}
impl From<io::Error> for IdentifyError {
fn from(source: io::Error) -> Self {
Self::IoError { source }
}
}
impl IdentifyError {
pub(crate) fn not_found(path: &std::path::Path, source: io::Error) -> Self {
Self::PathNotFound {
path: path.to_path_buf(),
source,
}
}
}