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
96
97
98
99
100
101
//! Shared FNV-1a (64-bit) hashing behind the record/replay cassette match keys.
//!
//! Two cassette-key digests use FNV-1a: [`Stdin::content_digest`](crate::Stdin)
//! (the stdin *source identity*) and the opt-in `MatchPolicy` digest (cwd +
//! selected env values) — both in the `record` feature. They deliberately avoid
//! `std`'s [`DefaultHasher`](std::collections::hash_map::DefaultHasher), whose
//! output may change between Rust releases: a digest recorded today must replay
//! **bit-for-bit identically** tomorrow and — more sharply — must still equal the
//! digests already written into committed cassette fixtures. FNV-1a is a fixed
//! algorithm over two hard-coded 64-bit constants, so it is stable across releases
//! by construction.
//!
//! This module is the **single** home of those constants and the mix loop. Each
//! call site used to define its own copy; a constant edited in one but not the
//! other would silently invalidate every already-recorded cassette (the recomputed
//! digest stops matching the stored one), surfacing not as a build error but as a
//! baffling [`CassetteMiss`](crate::Error::CassetteMiss) at replay. Centralising
//! them here makes that drift impossible: there is one definition to change, and
//! changing it is — by definition — a cassette-format break.
/// FNV-1a 64-bit offset basis (the canonical constant).
///
/// **Do not change.** This value is baked into every cassette digest ever
/// recorded; altering it silently invalidates existing fixtures (they replay as a
/// `CassetteMiss`, not a build error).
const OFFSET: u64 = 0xcbf2_9ce4_8422_2325;
/// FNV-1a 64-bit prime (the canonical constant). **Do not change** — see
/// [`OFFSET`].
const PRIME: u64 = 0x0000_0100_0000_01b3;
/// An incremental 64-bit FNV-1a hash, seeded from the fixed [`OFFSET`] basis.
///
/// Encapsulating the seed is the point: a caller obtains a hasher already at the
/// correct starting state and can only fold bytes in, so it cannot accidentally
/// start from the wrong basis — the precise footgun that would silently invalidate
/// recorded cassettes. Fold bytes with [`mix`](Self::mix) in a deterministic
/// order, then read the result with [`finish`](Self::finish).
pub ;