use std::fmt;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum LockzippyError {
#[error("ciphertext length {0} is not a multiple of AES block size 16")]
InvalidCiphertextLength(usize),
#[error("invalid AES properties length {0} (expected at least 2 bytes)")]
InvalidProperties(usize),
#[error("invalid NumCyclesPower {0} (valid range 0..=24)")]
InvalidNumCyclesPower(u8),
#[error("AES-CBC decrypt/unpad error: {0}")]
DecryptError(String),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
}
impl LockzippyError {
pub fn decrypt<T: fmt::Display>(msg: T) -> Self {
LockzippyError::DecryptError(msg.to_string())
}
}
pub type LockzippyResult<T> = Result<T, LockzippyError>;