use crate::pgp;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("The name is not a valid fingerprint or a known special name")]
BadName,
#[error("Base directory is not a store")]
NotAStore,
#[error("The data was not valid OpenPGP cert or key in binary format")]
BadData(#[from] pgp::Error),
#[error("Functionality is not supported on this platform: {0}")]
UnsupportedPlatform(String),
#[error("IO error")]
IoError(#[from] std::io::Error),
#[error(transparent)]
Other(#[from] Box<dyn std::error::Error + Send + Sync>),
}
impl From<walkdir::Error> for Error {
fn from(error: walkdir::Error) -> Self {
Self::Other(std::io::Error::from(error).into())
}
}
impl From<anyhow::Error> for Error {
fn from(error: anyhow::Error) -> Self {
Self::Other(<Box<dyn std::error::Error + Send + Sync + 'static>>::from(
error,
))
}
}
#[derive(thiserror::Error, Debug)]
pub(crate) enum InternalError {
#[error("The path does not represent a fingerprint")]
BadFingerprintPath,
#[error("The path is not in the store")]
PathNotInStore,
}