use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DecryptError {
InvalidInput,
DecompressionFailed,
InvalidEncoding,
}
impl fmt::Display for DecryptError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
Self::InvalidInput => "输入数据格式无效",
Self::DecompressionFailed => "解压缩失败",
Self::InvalidEncoding => "解密结果不是合法的 UTF-8",
})
}
}
impl std::error::Error for DecryptError {}
pub trait LyricsDecrypter {
fn decrypt(&self, input: &str) -> Result<String, DecryptError>;
fn decrypt_bytes(&self, input: &[u8]) -> Result<Vec<u8>, DecryptError>;
}