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
//! Persisted record + reservation-outcome state machine.
use SystemTime;
/// Persisted idempotency record returned on a replay. Banks need an
/// invariant view of the captured response — the store rebuilds this from
/// its persisted columns when the second caller asks to replay.
///
/// `response_headers` is an opaque blob produced by [`super::encode_headers`]
/// at capture time and consumed by [`super::decode_headers`] on replay. The
/// blob carries every end-to-end header the handler returned, including
/// `Location`, `ETag`, cache directives, and `Content-Type` — replaying
/// only the status + body would silently drop these and give a retry
/// different observable behaviour from the original execution.
/// Outcome of an atomic `reserve_or_fetch` call.
///
/// The middleware uses this state machine to decide whether to run the
/// handler, replay a cached response, or reject. Exactly one caller per
/// `(principal, key)` ever gets `Reserved` — that's the contract banking
/// flows like transfers rely on.