use bincode::ErrorKind;
use std::io::Error as IoError;
use thiserror::Error;
pub type Result<T, E = Error> = std::result::Result<T, E>;
#[derive(Debug, Error)]
#[allow(missing_docs)]
pub enum Error {
#[error("An error during compression or decompression.")]
Compression,
#[error("An error during initializing CBC-AES cipher instance.")]
Cipher(String),
#[error("An error within the symmetric encryption process.")]
Encryption,
#[error("An error within the symmetric decryption process({})", _0)]
Decryption(String),
#[error("A generic I/O error")]
Io(#[from] IoError),
#[error("Generic error({})", _0)]
Generic(String),
#[error("Serialisation error")]
Bincode(#[from] Box<ErrorKind>),
#[error("deserialization")]
Deserialise,
#[error("num parse error")]
NumParse(#[from] std::num::ParseIntError),
#[error("Rng error")]
Rng(#[from] rand::Error),
#[error("Unable to obtain lock")]
Poison,
}