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
//! [`JobId`]: the strongly-typed identifier for a row in the `jobs`
//! table.
//!
//! Why a newtype wrapping `Uuid` rather than `Uuid` directly:
//!
//! - **Type safety**: a function expecting a `JobId` cannot be called
//! with an arbitrary `Uuid` (e.g., a user-id) without an explicit
//! conversion. This catches a real class of bugs at compile time.
//! - **One place to change the id generator**: if we ever want to move
//! from `Uuid::now_v7` to a snowflake id or a u128, only this file
//! changes.
//! - **Layered representations**: the `sqlx(transparent)` and
//! `serde(transparent)` attributes mean the type behaves identically
//! to the wrapped `Uuid` over the wire and in the database, so the
//! wrapper is invisible to consumers but visible to the type checker.
//!
//! Why Uuid v7 specifically: see the "Design decisions" section of
//! `docs/architecture.md`. The short version is that v7 is time-ordered
//! so insertions stay localised to the rightmost BTree pages, while v4
//! would scatter writes across the entire index.
use ;
use fmt;
use Uuid;
/// A typed identifier for a [`crate::Job`]. Wraps a `Uuid` (v7) with
/// transparent encoding so the JSON/DB representation is just a UUID
/// string.
;