use std::error::Error;
use std::fmt::{Debug, Formatter};
use std::string::ToString;


#[derive(Debug)]
pub enum DatError{
    // sign
    UnknownSignAlgorithm,
    ParseSignKeyError,
    ParseVerifyKeyError,
    VerifyError,

    // crypt
    UnknownCryptAlgorithm,
    ParseCryptKeyError,
    EncryptError,
    DecryptError,

    // DatKey
    UnSupportDatKeyVersion,
    InvalidDatKeyFormat,
    UnSupportSignKeyIsVerifyOnly,
    NoAvailableKey,

    // Dat
    InvalidDatFormat,
    InvalidDatKidFormat,

    // etc
    InvalidBase64Format,
    Utf8EncodeError,
    IoError,
}

impl Error for DatError {}

impl std::fmt::Display for DatError {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "Dat{}", self.to_string())
    }
}
