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
//! Deterministic identifiers for test fixtures.
//!
//! Production ids ([`Id::new`](klauthed_core::id::Id::new)) are random/time-based
//! and so differ on every run, which makes assertions and golden files brittle.
//! These helpers mint **stable** ids from a `u64` seed: the same seed always
//! yields the same [`Id<T>`], so fixtures are reproducible across runs and across
//! marker types.
use Id;
use Uuid;
/// A reproducible [`Id<T>`] derived from the seed `n`.
///
/// The same `n` always produces the same id (for any marker type `T`), and
/// distinct `n` values produce distinct ids. The seed is placed in the low 64
/// bits of the underlying [`Uuid`], so the rendered id is easy to recognize at a
/// glance (e.g. seed `7` → `...-0000000000000007`).
///
/// This is deliberately *not* a valid versioned UUID; it is a test fixture id,
/// not a generated production id.
///
/// ```
/// use klauthed_testing::ids::seeded_id;
/// use klauthed_core::id::Id;
///
/// struct User;
/// type UserId = Id<User>;
///
/// // Stable across calls...
/// assert_eq!(seeded_id::<User>(7), seeded_id::<User>(7));
/// // ...and distinct across seeds.
/// assert_ne!(seeded_id::<User>(7), seeded_id::<User>(8));
/// // The seed is visible in the low bits.
/// assert!(seeded_id::<User>(7).to_string().ends_with("000000000007"));
/// ```
Sized>
/// The nil (all-zero) [`Id<T>`], useful as a sentinel or "unset" fixture value.
///
/// ```
/// use klauthed_testing::ids::nil_id;
/// use klauthed_core::id::Id;
///
/// struct Order;
/// assert!(nil_id::<Order>().is_nil());
/// ```
Sized>