rose_squared_sdk/error.rs
1//! Error types for the Rose Squared SDK.
2
3use thiserror::Error;
4
5/// The primary error type for all Rose Squared operations.
6#[derive(Error, Debug)]
7pub enum VaultError {
8 /// Error during key derivation (Argon2id or HKDF).
9 #[error("KDF error: {0}")]
10 Kdf(String),
11
12 /// Error during cryptographic operations (AES-GCM).
13 #[error("Crypto error: {0}")]
14 Crypto(String),
15
16 /// A ciphertext was tampered with or corrupted on the server.
17 #[error("Tampered entry detected (GCM MAC mismatch)")]
18 Tampered,
19
20 /// A SWiSSSE volume limit was exceeded.
21 #[error("Volume limit exceeded: {max}")]
22 VolumeLimitExceeded {
23 /// The maximum number of entries allowed.
24 max: usize
25 },
26
27 /// The requested document could not be found in the state table.
28 #[error("Document not found: {0}")]
29 DocNotFound(String),
30
31 /// Standard I/O error.
32 #[error("I/O error: {0}")]
33 Io(#[from] std::io::Error),
34
35 /// Error from the underlying storage backend.
36 #[error("Storage error: {0}")]
37 StorageError(String),
38
39 /// Error during bincode serialization/deserialization.
40 #[error("Serialization error: {0}")]
41 Serialization(#[from] bincode::Error),
42}