use thiserror::Error;
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq, Error)]
pub enum Error {
#[error("key must be 64 bytes")]
InvalidKeyLength,
#[error("invalid hex encoding")]
InvalidHex,
#[error("invalid base64 encoding")]
InvalidB64,
#[error("invalid base32rfc encoding")]
InvalidB32,
#[error("invalid base32crockford encoding")]
InvalidC32,
#[error("invalid UTF-8")]
InvalidUtf8,
#[error("invalid format string")]
InvalidFormat,
#[error("invalid scheme")]
InvalidScheme,
#[error("unknown scheme")]
UnknownScheme,
#[error("unknown encoding")]
UnknownEncoding,
#[error("enc failed")]
EncryptionFailed,
#[error("enc failed: empty plaintext")]
EmptyPlaintext,
#[error("dec failed: empty payload")]
EmptyPayload,
#[error("dec failed: payload too short")]
PayloadTooShort,
#[error("decryption failed")]
DecryptionFailed,
#[error("invalid block length")]
InvalidBlockLength,
#[error("decoding failed: scheme marker mismatch")]
SchemeMarkerMismatch,
#[cfg(feature = "legacy")]
#[error("legacy fallback produced invalid output (likely encoding mismatch)")]
InvalidLegacyOutput,
}
impl From<hex::FromHexError> for Error {
fn from(_: hex::FromHexError) -> Self {
Error::InvalidHex
}
}