1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! [`crate::InboxStore::process`]'s error.
use fmt;
use ;
/// Whose fault it was. Split so the caller can tell "my handler failed" (record it, `nak`) from
/// "the inbox could not be read or written" (record nothing, `nak`).
///
/// ```
/// use reliar_inbox::InboxProcessError;
///
/// #[derive(Debug)]
/// struct StoreError;
/// impl std::fmt::Display for StoreError {
/// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
/// f.write_str("store unavailable")
/// }
/// }
/// impl std::error::Error for StoreError {}
///
/// let err: InboxProcessError<StoreError, std::convert::Infallible> =
/// InboxProcessError::Store(StoreError);
/// assert_eq!(err.to_string(), "inbox store failed: store unavailable");
/// ```
/// Maps [`Self::Store`] to the store error's own [`FailureKind`] and [`Self::Handler`] to
/// **[`FailureKind::Transient`]** — a handler failure is retried by the broker's redelivery, and
/// the inbox has no authority to call a message permanently dead (ADR 0042 §4).
///
/// ```
/// use reliar_core::{Classify, FailureKind};
/// use reliar_inbox::InboxProcessError;
///
/// #[derive(Debug)]
/// struct StoreError;
/// impl Classify for StoreError {
/// fn kind(&self) -> FailureKind {
/// FailureKind::Permanent
/// }
/// }
///
/// #[derive(Debug)]
/// struct HandlerError;
///
/// // A handler failure is always `Transient`, regardless of the store error's own kind.
/// let err: InboxProcessError<StoreError, HandlerError> = InboxProcessError::Handler(HandlerError);
/// assert_eq!(err.kind(), FailureKind::Transient);
/// ```