datex_crypto_facade/
error.rs1use alloc::string::String;
2use core::fmt::Display;
3
4#[derive(Debug, Clone)]
5pub enum CryptoError {
6 Other(String),
7 KeyGeneration,
8 KeyExport,
9 KeyImport,
10 Encryption,
11 Decryption,
12 Signing,
13 Verification,
14}
15
16impl Display for CryptoError {
17 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
18 match self {
19 CryptoError::Other(msg) => core::write!(f, "Crypto: {}", msg),
20 CryptoError::KeyGeneration => {
21 core::write!(f, "CryptoError: Key generation failed")
22 }
23 CryptoError::KeyExport => {
24 core::write!(f, "CryptoError: Key export failed")
25 }
26 CryptoError::KeyImport => {
27 core::write!(f, "CryptoError: Key import failed")
28 }
29 CryptoError::Encryption => {
30 core::write!(f, "CryptoError: Encryption failed")
31 }
32 CryptoError::Decryption => {
33 core::write!(f, "CryptoError: Decryption failed")
34 }
35 CryptoError::Signing => {
36 core::write!(f, "CryptoError: Signing failed")
37 }
38 CryptoError::Verification => {
39 core::write!(f, "CryptoError: Verification failed")
40 }
41 }
42 }
43}