1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
5
6pub type DecryptResult<T> = std::result::Result<T, DecryptError>;
8
9#[derive(Debug, Clone, PartialEq, Eq, Error)]
11pub enum Error {
12 #[error("secret identifier must not be empty")]
14 InvalidIdentifier,
15 #[error("{field} contains invalid characters: {value}")]
17 InvalidCharacters {
18 field: &'static str,
20 value: String,
22 },
23 #[error("{field} must not be empty")]
25 EmptyComponent {
26 field: &'static str,
28 },
29 #[error("uri must start with secrets://")]
31 InvalidScheme,
32 #[error("uri is missing {field}")]
34 MissingSegment {
35 field: &'static str,
37 },
38 #[error("uri contains unexpected extra segments")]
40 ExtraSegments,
41 #[error("invalid version segment: {value}")]
43 InvalidVersion {
44 value: String,
46 },
47 #[error("encryption algorithm not supported: {0}")]
49 UnsupportedAlgorithm(String),
50 #[error("encryption algorithm {0} requires the 'xchacha' feature")]
52 AlgorithmFeatureUnavailable(String),
53 #[error("crypto error: {0}")]
55 Crypto(String),
56 #[error("storage error: {0}")]
58 Storage(String),
59 #[error("{entity} not found")]
61 NotFound {
62 entity: String,
64 },
65}
66
67#[derive(Debug, Clone, PartialEq, Eq, Error)]
69pub enum DecryptError {
70 #[error("message authentication failed")]
72 MacMismatch,
73 #[error("key provider error: {0}")]
75 Provider(String),
76 #[error("invalid envelope: {0}")]
78 InvalidEnvelope(String),
79 #[error("crypto error: {0}")]
81 Crypto(String),
82}