use crate::ID_LEN;
use thiserror::Error;
#[derive(Clone, Debug, Error)]
pub enum IdError {
#[error("{0}")]
DecodeHex(blake3::HexError),
#[cfg(feature = "base58")]
#[error("{0}")]
DecodeBase58(bs58::decode::Error),
#[error("expected {ID_LEN} bytes, but got {}{}", .0.unwrap_or(ID_LEN), if .0.is_none() { "+" } else { "" })]
InvalidLength(Option<usize>),
}
impl From<blake3::HexError> for IdError {
fn from(input: blake3::HexError) -> Self {
Self::DecodeHex(input)
}
}
#[cfg(feature = "base58")]
impl From<bs58::decode::Error> for IdError {
fn from(input: bs58::decode::Error) -> Self {
Self::DecodeBase58(input)
}
}