spectre/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum SpectreError {
5    #[error("Invalid algorithm version: {0}")]
6    InvalidAlgorithm(u32),
7    
8    #[error("Invalid result type: {0}")]
9    InvalidResultType(String),
10    
11    #[error("Invalid key purpose: {0}")]
12    InvalidKeyPurpose(String),
13    
14    #[error("Invalid counter value: {0}")]
15    InvalidCounter(i64),
16    
17    #[error("Invalid file format: {0}")]
18    InvalidFileFormat(String),
19    
20    #[error("User key derivation failed")]
21    KeyDerivationFailed,
22    
23    #[error("Password generation failed")]
24    PasswordGenerationFailed,
25    
26    #[error("Encryption failed")]
27    EncryptionFailed,
28    
29    #[error("Decryption failed")]
30    DecryptionFailed,
31    
32    #[error("User secret mismatch")]
33    UserSecretMismatch,
34    
35    #[error("File I/O error: {0}")]
36    Io(#[from] std::io::Error),
37    
38    #[error("JSON error: {0}")]
39    Json(#[from] serde_json::Error),
40    
41    #[error("Missing required field: {0}")]
42    MissingField(String),
43}
44
45pub type Result<T> = std::result::Result<T, SpectreError>;
46