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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
//! The three facts a stored [`Rate`] states about itself — [`Timebase`](super::super::Timebase)'s
//! storage face over the other reading, and the one place the reciprocal is deliberately NOT taken.
//!
//! ```text
//! fps_num i32 ┐ the RATE's own pair: 30000/1001 for NTSC video
//! fps_den i32 ┘ and NOT 1001/30000, which is the timebase of it
//! ```
//!
//! # The columns hold the reading the field is named for
//!
//! `mediatime::Rate::to_timebase` swaps the pair, so a rate and its timebase are one value in two
//! readings and either could in principle be what a column holds. This citizen stores the RATE, and
//! the reason is that any other rule needs something in the schema to carry it:
//!
//! - A client sends `30000/1001` and the column holds `30000/1001`, so a query is the number that
//! was sent rather than a division away from it.
//! - Two `INTEGER` columns look the same whichever convention filled them, so a table storing the
//! reciprocal would be indistinguishable from one storing the value, and the only place the
//! difference could live is a comment.
//! - A stream declaring both a rate and a timebase stores both, in two fields, each in its own
//! reading — which is what the two citizens' rosters already say by mirroring each other entry for
//! entry rather than by one being the other's storage form.
//!
//! Everything else here is the timebase's storage face verbatim, because the shape is: two `i32`s
//! reduced through one function, bound as two placeholders, read back by name, and carried in a
//! cursor as eight big-endian bytes. See [`Rate::reduced`] for the reduction and
//! [`Timebase`](super::super::Timebase)'s own storage module for the argument that a silent
//! reduction mismatch is the failure worth guarding.
//!
//! # The second bite: `record` retires `ColumnKind`/`Carrier`/`Assemble`
//!
//! [`Rate`] now carries `record(write = "Rate::head_reduced")` (ingraph#380, door (a) of
//! ingraph#377): the fragment HEAD took a whole-value transform seat, `fn(&Self) -> Self`, spent at
//! the bind and the cursor's write alike — the shape a per-field `fn(&T) -> T` could never spell,
//! a gcd reduction reading BOTH halves. [`Rate::head_reduced`] fills it, and its own body is
//! [`Rate::reduced`] rebuilt into a [`Rate`], so the emitted `Carrier` now pushes the identical pair
//! the hand one used to. The emitted `ColumnKind` names the same two columns this module's own
//! [`SEGMENTS`] does — pinned by a test that reads `<Rate as ColumnKind>::SEGMENTS` through the
//! trait rather than by naming the constant, so it now reads the EMITTED impl unmodified.
//!
//! # The third bite: the cursor byte form becomes a MOUNT
//!
//! The parallel hand kit is gone. `record(<db>(cursor = "RateCursor"))` (ingraph#387, door (d) of
//! ingraph#377) names a codec per dialect and the emission's cursor row delegates to it instead of
//! framing, so the eight flat bytes this citizen has always written are now the DECLARED byte form
//! rather than an impl hung beside the declaration. [`RateCursor`] is that codec and the bytes are
//! unchanged — outstanding page tokens keep resuming, which is the one property a migration of a
//! byte form owes.
//!
//! Two facts made the mount legal here, and neither is the comparison door:
//!
//! - **The cursor seam names no driver.** It is keyed on `crate::dialect`'s markers, which ship
//! ungated, so naming three dialects costs this crate no feature wall — where
//! `record(<db>(comparison = "…"))` is keyed on `sqlx`'s own backend types and would gate this
//! citizen's lowering behind features the manifest deliberately does not have. That door stays
//! shut and [`comparison`](super::comparison) stays hand-written; see it for the full argument.
//! - **A mounted read raises nothing** (ingraph#394). The framed read rebuilds through the
//! construction protocol, so `builder(fallible)` had nowhere to put an `Err` and the pair was
//! refused by name; a codec hands back a built value and the emission applies only the head `read`
//! mirror, so the protocol is never consulted. The exemption holds for exactly as long as EVERY
//! declared dialect mounts — which is why all three name [`RateCursor`] rather than some riding
//! the framed default.
//!
//! What this leaves for THIS module to write by hand:
//!
//! - [`RateColumnError`] and [`assembled`] — the one decode rule, unmoved, because [`RateCursor`]
//! still needs it directly and the emitted raise now reaches it too, through [`CheckedFps`] below.
//! - [`RateCursor`] — the codec the declaration names. A TYPE rather than an impl on [`Rate`]: the
//! seat takes one implementor because `encode` and `decode` are duals, and a value that mounts per
//! dialect has no `CursorValue` row at all, the two being `E0119` against the framework's blanket.
//! - [`CheckedFps`] — the raise's OWN remaining question, independent of `write`/`read` AND, it
//! turns out, of `sqlx` itself (mediagraph#86): a wrapped fragment's raise rebuilds through the
//! remote's own constructor, and `mediatime::Rate` has none of the infallible shape `builder`'s
//! default expects. See its own doc for why a trait was the answer and not a new `mediatime`
//! constructor. Its error is [`RateColumnError`] — the same one [`assembled`] already answers —
//! so the trait and its impl stand UNGATED beside their neighbours here; the one seat that is
//! actually `sqlx`'s is the separate, gated `impl From<RateColumnError> for sqlx::Error` right
//! after it, which is what discharges the `From<E> for sqlx::Error` a fallible protocol owes.
use ;
use crateCursorCodec;
use crate::;
use mediatime as mt;
use Rate;
/// The numerator's segment — the name [`comparison`](super::comparison) frames its predicate at.
///
/// `record`'s own emission now names the columns for the width, the bind and the raise — this pair
/// is what is LEFT to hand-name, because the hand crossing in [`comparison`](super::comparison) is
/// the one face `record` was not asked to mount (door (d), the family-generic feature reason). Gated
/// with that module, its one remaining reader.
pub const NUM: &FieldName = new;
/// The denominator's segment.
pub const DEN: &FieldName = new;
/// **The two columns a rate spans, in [`comparison`](super::comparison)'s own reading** — the same
/// two names the emitted `ColumnKind` gives them, restated here because the hand crossing frames its
/// predicate by NAME rather than by reading the trait.
///
/// The same two SHORT names the timebase citizen uses, and the collision is only apparent: a field
/// lends its own name to its segments, so a `fps: Rate` beside a `timebase: Timebase` renders
/// `fps_num`/`fps_den` and `timebase_num`/`timebase_den` — four columns, no shared spelling. What
/// the short names cost is that a `flattened` rate and a `flattened` timebase in one row would
/// collide, which the framework refuses BY NAME at the declaration rather than silently prefixing
/// one away.
pub const SEGMENTS: & = &;
/// A pair of columns does not hold a rate, and this says which invariant they broke.
///
/// A decode error rather than a parse error, and a separate type from
/// [`ParseRateError`](super::ParseRateError): nothing here was spelled, so there is no separator to
/// be missing and no half that failed to be an integer. What is left is exactly the two domain
/// rules, met on the way in from a database rather than from a client.
/// The two columns as one value, or the invariant they broke — shared by the row decode and the
/// cursor, so a rate arriving from a database and one arriving from a page token are admitted by the
/// same rule.
/// A [`Result`]-shaped mirror of [`mt::Rate::try_fps`] — the shape the declaration's
/// `builder(entry = "checked_fps", fallible)` needs at ITS entry, reachable as
/// `mt::Rate::checked_fps` once this trait is in scope.
///
/// # Why a trait over a foreign type
///
/// The construction protocol's `fallible` word appends a bare `?` to the entry call, and that only
/// type-checks against a [`Result`] — an `Option` and a `Result` share no `FromResidual` for one to
/// answer through the other, so naming `try_fps` there directly is `E0277` at the raise.
/// `mediatime::Rate` has no constructor of the `Result` shape on its own: [`mt::Rate::fps`] panics on
/// the rows this citizen exists to refuse gracefully, which a raise reading untrusted columns cannot
/// risk, and [`mt::Rate::try_fps`] answers the `Option` this trait converts. A LOCAL trait over the
/// FOREIGN type is the orphan rule's own answer to closing that gap without asking `mediatime` to
/// grow a constructor only this crate would call.
///
/// # One validation, not two
///
/// [`checked_fps`](Self::checked_fps) is [`assembled`] called again rather than
/// [`mt::Rate::try_fps`] called afresh: the domain rules a stored pair can break are exactly
/// [`assembled`]'s two, and by the time this seat runs, the column read has already crossed `den`
/// into a [`NonZeroI32`] — so only [`RateColumnError::NegativeHalf`] is left to answer. Reusing
/// [`assembled`] is what keeps the emitted raise and [`CursorValue::read_cursor`] admitting a stored
/// pair by one rule rather than by two an editor has to keep in step.
pub