1#[derive(Debug, thiserror::Error, PartialEq)]
3pub enum UrnParseError {
4 #[error(
5 "URN must have exactly 4 colon-separated segments (urn:secrets-rs:<source_id>:<name>), got {0}"
6 )]
7 WrongSegmentCount(usize),
8
9 #[error("URN scheme must be 'urn', got '{0}'")]
10 InvalidScheme(String),
11
12 #[error("URN NID must be 'secrets-rs', got '{0}'")]
13 InvalidNid(String),
14
15 #[error("source_id must not be empty")]
16 EmptySourceId,
17
18 #[error(
19 "source_id '{0}' contains characters that are invalid in a URN source_id; \
20 allowed: literal ASCII letters, digits, and `-._~!$&'()*+,;=@/` \
21 (percent-encoded sequences are not accepted)"
22 )]
23 InvalidSourceId(String),
24
25 #[error("name must not be empty")]
26 EmptyName,
27}
28
29#[derive(Debug, thiserror::Error)]
31pub enum SourceError {
32 #[error("secret '{name}' not found in source")]
33 NotFound { name: String },
34
35 #[error("source error: {0}")]
36 Other(String),
37}
38
39#[derive(Debug, thiserror::Error, PartialEq)]
41pub enum SourceRegisterError {
42 #[error(
43 "source id '{0}' is empty or contains characters that are invalid in a URN source_id; \
44 allowed: literal ASCII letters, digits, and `-._~!$&'()*+,;=@/` \
45 (percent-encoded sequences are not accepted)"
46 )]
47 InvalidSourceId(String),
48}
49
50#[derive(Debug, thiserror::Error)]
52pub enum BindError {
53 #[error("no source registered with id '{source_id}'")]
54 SourceNotFound { source_id: String },
55
56 #[error("secret '{name}' not found in source '{source_id}'")]
57 NameNotFound { source_id: String, name: String },
58
59 #[error("type conversion failed for secret '{urn}': {detail}")]
60 TypeConversion { urn: String, detail: String },
61
62 #[error("source error for '{urn}': {source}")]
63 Source { urn: String, source: SourceError },
64}
65
66#[derive(Debug, thiserror::Error)]
68#[error("secret '{urn}' has not been bound; call bind() or bind_all() first")]
69pub struct UnboundError {
70 pub urn: String,
71}