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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
//! WHAT THE BYTES ARE ENCODED WITH: the three codec vocabularies a stream descriptor carries, and
//! the newtypes that make one a column.
//!
//! [`VideoCodec`], [`AudioCodec`] and [`SubtitleCodec`] are ONE INVARIANT read at three media types
//! — *a codec name FFmpeg knows, in the lowercase canon, or an open escape for one it does not* —
//! and they arrive as a FAMILY for [`primitives::lang`](crate::primitives::lang)'s reason rather
//! than despite the one-name-per-invariant law. A track table has three codec seats and they hold
//! three DIFFERENT rosters: `h264` is not a value an audio seat may take, `aac` is not one a video
//! seat may, and collapsing them into one type would make the column stop saying which.
//!
//! # The value space, and the door that makes it canonical
//!
//! Upstream each type is a `#[non_exhaustive]` roster enum over FFmpeg n9.0's names with an
//! `Other(SmolStr)` arm — the lossless escape for a codec added after the table was generated. So
//! the vocabulary is OPEN, and every text is a codec: [`FromStr`](core::str::FromStr) upstream
//! returns [`Infallible`](core::convert::Infallible), and that infallibility runs through every
//! face here.
//!
//! **One fold per question, applied at the DOOR.** `new` is the one route in and it goes through
//! the upstream slug TABLE, so `"H264"`, `"h264"` and a `VideoCodec::other("h264")` built by hand
//! upstream all become the named `H264` variant here. That is worth stating precisely because
//! upstream it is NOT true: `mediaframe::VideoCodec::other("h264")` is an `Other` holding text a
//! named variant already spells, and it compares unequal to that variant under the derived
//! [`Eq`](core::cmp::Eq). This house's door re-runs the table, so no such value exists INSIDE a
//! citizen — which is what makes [`as_str`](VideoCodec::as_str) injective over the value space, and
//! therefore what makes the ordering below consistent with the equality beside it.
//!
//! # Ordering is ALPHABETICAL, and it is this crate's row rather than an inherited one
//!
//! None of the three upstream enums derives [`Ord`](core::cmp::Ord) — declaration order over a
//! generated roster is not a meaning anyone should depend on, and upstream is right not to publish
//! one. What each citizen here implements instead is the order over its CANONICAL SLUG, which is
//! [`Language`](crate::primitives::lang::Language)'s own bargain word for word: *it orders the
//! SPELLINGS and says nothing about the codecs* — `av1` sorts before `h264` and neither fact is
//! about compression — and it earns its place for that type's reason, being total, stable, and
//! therefore a usable cursor key.
//!
//! It also AGREES with the column: the stored form is the same slug's UTF-8, whose `TEXT` order is
//! bytewise, so `ORDER BY "codec"` and this [`Ord`](core::cmp::Ord) walk one sequence. An order the
//! engine and the type disagreed about is what makes a keyset page skip a row, which is the reason
//! this row is written rather than left to a caller.
//!
//! # THE FACES, and the two that are REFUSED BY NAME
//!
//! The roster is [`primitives::lang`](crate::primitives::lang)'s subtag citizenship, which is the
//! same SHAPE this house has — one word, one text column, its own scalar. See
//! [`codec_citizen`](self) for the table. Two rows on it are not taken here, and neither is silent:
//!
//! - **[`DelegatesId`](crate::DelegatesId) — REFUSED, and the refusal is a fact about the
//! REPRESENTATION rather than about codecs.** That trait is a TRANSPARENCY ASSERTION: `Self`
//! holds an admitted [`Id`](crate::Id) and adds nothing a key can see. A subtag can make it
//! because it IS a [`Utf8Bytes`](smol_bytes::Utf8Bytes) under a grammar; a citizen here holds a
//! foreign ENUM, which is not an admitted member and which the assertion would therefore be false
//! about. [`Id`](crate::Id) is sealed, so there is no second road, and NO citizen of
//! [`mediatime`](crate::primitives::mediatime) takes this row either — the house's answer for a
//! newtype over a foreign value, met here for the same reason.
//!
//! What it costs is a codec at a KEY position — an `#[ingraph(id)]`, an `#[ingraph(group)]` — and
//! the escape is the one [`Timestamp`](crate::Timestamp)'s Mongo row names: a column typed as the
//! text itself, with the conversion at the seat. `codec.as_str()` is that conversion and it is
//! lossless, so *count the tracks by codec* is a `String` group key away rather than unavailable.
//! - **[`CollectionElement`](crate::CollectionElement) and the quantified `Vec` reading — REFUSED**,
//! on [`Timebase`](crate::primitives::mediatime::Timebase)'s ruling and in its words. A TRACK
//! declares ONE codec; a `Vec<VideoCodec>` is not a question anyone asks of a track, and a file
//! holding several is a collection of TRACKS whose codecs are each that track's own column. The
//! day a caller has a real list of codecs the rows are two lines, which is this crate's *a name
//! arrives when a caller does* read at face scale.
//!
//! # The wire
//!
//! Behind `async-graphql`: the three types as SCALARS, each its own — the shape a value that is one
//! word has, and the one [`primitives::lang`](crate::primitives::lang)'s subtags take. There is no
//! operand newtype beside any of them and no input object restating one.
//!
//! ```text
//! scalar VideoCodec scalar AudioCodec scalar SubtitleCodec
//!
//! input VideoCodecFilter { eq/ne: VideoCodec in/notIn: [VideoCodec!]
//! gt/gte/lt/lte: VideoCodec }
//! ```
//!
//! All EIGHT of `ScalarFilter`'s operators are honest here, which is not a thing every vocabulary
//! can say: the four identity words read the canonical slug, and the four ordering words read the
//! alphabetical order the section above argues for and names as a spelling order.
//!
//! # The comparison face is DELEGATED, and there is no comparison type of this crate's own
//!
//! No `SqlVideoCodecComparison` stands beside these three, and the absence is the one-column shape
//! rather than a missing face. `ScalarFilter<VideoCodec, VideoCodecWire>` crosses into `ingraph`'s
//! own `SqlScalarComparison<String, Db>` through the framework's blanket, because the storage value
//! IS the canonical slug — so every operator is lowered by a comparison this crate already ships
//! and every refusal it can make is one that already has a name.
//!
//! That is exactly [`primitives::lang`](crate::primitives::lang)'s subtags again, and it is what
//! separates a one-column citizen from [`Timebase`](crate::primitives::mediatime::Timebase)'s: a
//! value that DECOMPOSES needs a comparison holding its halves and a refusal vocabulary for the ways
//! they can disagree, and a value that is one word needs neither. What has to be proven of this
//! house is therefore not that the pieces exist but that the FOLD reaches storage and the ORDER
//! reaches the engine, which is what `tests/codec_citizen.rs` runs.
pub use ;
pub use ;
pub use ;
/// Generate one codec type's CITIZENSHIP — the rows that are the same row for all three, and the
/// reason this house has a macro at all.
///
/// | row | what it says |
/// |---|---|
/// | [`Display`](core::fmt::Display), [`Debug`](core::fmt::Debug) | the canonical slug, and nothing around it |
/// | [`FromStr`](core::str::FromStr) | the parse, forwarded to the type's own door — [`Infallible`](core::convert::Infallible) |
/// | [`AsRef<str>`], [`From`] × 4 | the text out, the foreign value in and out |
/// | [`Ord`](core::cmp::Ord), [`PartialOrd`](core::cmp::PartialOrd) | the alphabetical order over the slug, which upstream does not publish |
/// | [`ToGraphqlInput`](crate::ToGraphqlInput) / [`ToGraphqlOutput`](crate::ToGraphqlOutput) | the wire crossing, both directions — the IDENTITY, the type being its own scalar |
/// | [`ScalarWire`](crate::ScalarWire) | what a filter over it is NAMED, and the eight operators' carrier |
/// | [`CompositeFilterMarker`](crate::CompositeFilterMarker) / [`DefaultMarker`](crate::DefaultMarker) | the interpretation a column is read under: the framework's COMPOSITE reading |
/// | [`ColumnKind`](crate::ColumnKind) | ONE column — the default, stated rather than inherited |
/// | [`StoredAs`](crate::StoredAs) / [`Carrier`](crate::Carrier) / [`Assemble`](crate::Assemble) / [`CursorValue`](crate::CursorValue) | the word, the bind, the decode and the keyset position |
/// | [`MongoCarrier`](crate::MongoCarrier) / [`MongoExtract`](crate::query::mongo::MongoExtract) | the same canonical slug as the BSON a document holds, and read back |
///
/// [`DelegatesId`](crate::DelegatesId) is NOT on it, and the module note above argues the refusal.
///
/// # The decode CANONICALISES and CANNOT FAIL, which is where this house parts from the subtags
///
/// [`primitives::lang`](crate::primitives::lang)'s macro carries a long note on its three reads
/// re-validating, because a `TEXT` column, a client's cursor and a foreign document can each hold a
/// string that names no subtag. Here they cannot: the `Other` arm means every string names a codec,
/// so the door is total and each of the three reads returns a value rather than a `Result` it could
/// fail.
///
/// That removes a refusal and keeps the CANONICALISATION, which is the half that was doing the
/// work. A column holding `H264` reads back as the named `H264` variant, because the read goes
/// through the same table the write path's value came through — so a row this crate wrote reads
/// back byte for byte, and a row someone else wrote reads back canonical.
///
/// What it costs is that a `TEXT` column typed as a codec can never be found to be WRONG. A column
/// holding `not a codec at all` decodes to `Other("not a codec at all")` rather than to an error,
/// and no face here will say otherwise. That is the open vocabulary's own bargain rather than this
/// crate's — it is what the escape arm IS — and the place it is visible is the roster:
/// [`is_registered`](VideoCodec::is_registered) is the question that separates a name FFmpeg knows
/// from one it does not, which is the honest form of the check a fallible decode would have been
/// pretending to make.
pub use codec_citizen;