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
//! The caller's business logic, run between the claim and the completion.
/// What [`crate::InboxStore::process`] runs between the claim and the completion, in the
/// caller's transaction. A trait rather than a closure parameter: an `AsyncFnOnce(&mut Tx)`
/// bound cannot be proven `Send` on stable Rust, and a boxed-future closure fails at the call
/// site โ both probed, both in ADR 0042 ยง5. Here the `&mut Tx` lifetime is quantified by
/// `handle` itself, so neither problem exists.
///
/// ```
/// use reliar_inbox::InboxHandler;
///
/// struct RecordOrder;
///
/// impl InboxHandler<()> for RecordOrder {
/// type Output = u64;
/// type Error = std::convert::Infallible;
///
/// async fn handle(&self, _tx: &mut ()) -> Result<Self::Output, Self::Error> {
/// Ok(42)
/// }
/// }
///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let output = RecordOrder.handle(&mut ()).await.unwrap();
/// assert_eq!(output, 42);
/// # }
/// ```