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
//! Failure classification shared by [`crate::Publisher`] and `OutboxStore` (`reliar-outbox`)
//! (ADR 0008, ADR 0032).
/// Implemented by every [`crate::Publisher::Error`] and `OutboxStore::Error`
/// (`reliar-outbox`) so a dispatcher can decide retry vs. dead without a downcast. Carried **by
/// the error type**, not by the publisher: the error value is what crosses a `JoinSet` boundary
/// into the dispatcher, so it must carry its own verdict (ADR 0008).
///
/// ```
/// use reliar_core::{Classify, FailureKind};
///
/// #[derive(Debug)]
/// enum MyPublishError {
/// Timeout,
/// PayloadTooLarge,
/// }
///
/// impl Classify for MyPublishError {
/// fn kind(&self) -> FailureKind {
/// match self {
/// Self::Timeout => FailureKind::Transient,
/// Self::PayloadTooLarge => FailureKind::Permanent,
/// }
/// }
/// }
///
/// assert_eq!(MyPublishError::Timeout.kind(), FailureKind::Transient);
/// ```
/// Whether a failure is worth retrying.
///
/// ```
/// use reliar_core::FailureKind;
///
/// assert_ne!(FailureKind::Transient, FailureKind::Permanent);
/// ```