use std::{io, error};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum InternalError {
#[error("[VachError::GenericError] {0}")]
OtherError(Box<dyn error::Error + Send + Sync>),
#[error("[VachError::MissingFeatureError] Unable to continue with operation, the cargo feature ({0}) is missing")]
MissingFeatureError(&'static str),
#[error("[VachError::ParseError] {0}")]
ParseError(String),
#[error("[VachError::IOError] {0}")]
IOError(#[from] io::Error),
#[error("[VachError::ValidationError] Invalid magic found in Header, possible incompatibility with given source. Magic found {0:?}")]
MalformedArchiveSource([u8; crate::MAGIC_LENGTH]),
#[error("[VachError::MissingResourceError] Resource not found: {0}")]
MissingResourceError(String),
#[error("[VachError::LeafAppendError] A leaf with the ID: {0} already exists. Consider changing the ID to prevent collisions")]
LeafAppendError(String),
#[error("[VachError::NoKeypairError] Unable to continue with cryptographic operation, as no keypair was supplied")]
NoKeypairError,
#[cfg(feature = "crypto")]
#[error("[VachError::CryptoError] {0}")]
CryptoError(aes_gcm::Error),
#[error("[VachError::RestrictedFlagAccessError] Tried to set reserved bit(s)!")]
RestrictedFlagAccessError,
#[error("[VachError::IDSizeOverflowError] The maximum size of any ID is: {}. The leaf with ID: {0} has an overflowing ID of length: {}", crate::MAX_ID_LENGTH, .0.len())]
IDSizeOverflowError(String),
#[error("The provided archive source has version: {}. While the current implementation has a spec-version: {}. The provided source is incompatible!", .0, crate::VERSION)]
IncompatibleArchiveVersionError(u16),
#[error("[VachError::SyncError] {0}")]
SyncError(String),
#[error("[VachError::CompressorDecompressorError]: {0}")]
#[cfg(feature = "compression")]
DeCompressionError(#[from] lz4_flex::frame::Error),
}