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
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
//! [`Symbology`]: which barcode standard a payload was read under — twenty-four named members and
//! one escape.
use fmt;
use Utf8Bytes;
use crate::;
/// The type name every `VNBarcodeObservation` writes in front of the word — what
/// [`Symbology::from_vision`] removes and the plain door does not.
const VISION_PREFIX: &str = "VNBarcodeSymbology";
/// **THE BARCODE STANDARD a payload was encoded in** — twenty-four named symbologies, plus an
/// escape for a word this vocabulary does not name.
///
/// ```text
/// 2D aztec data_matrix pdf417 micro_pdf417 qr micro_qr
/// RETAIL ean8 ean13 upce gs1_data_bar …_expanded …_limited
/// LINEAR codabar code39 (+3 variants) code93 code93i code128
/// i2of5 i2of5_checksum itf14 msi_plessey
/// ```
///
/// # It is a VOCABULARY and not a payload format
///
/// A symbology says how the bars were READ, not what the payload MEANS. A QR code carrying a URL
/// and one carrying a Wi-Fi credential are both `qr`; what separates them is the text, which is
/// [`BarcodeDetection`](super::BarcodeDetection)'s own field.
///
/// # It is DOMAIN-NEUTRAL, which is why it is here at all
///
/// A barcode is read off a photograph, a scanned invoice, a PDF page and a shipping label, and none
/// of those is a camera's business more than another's. That is the same sentence
/// [`Label`](super::Label) makes one file over, and it is the ruling that sent this cluster
/// upstream: the vision-flavoured payloads — poses, masks, landmark contours — stayed downstream,
/// and the ones a document graph would declare came here.
///
/// # OPEN, and the escape is why the wire face is a SCALAR
///
/// The roster is Apple's Vision list, hand-stated: [`VNBarcodeSymbology`] publishes exactly these
/// twenty-four. It was read out of a documentation page rather than out of a machine-readable
/// registry, so a decoder this crate has not met reads a standard this crate has not named — and
/// carrying that word is better than refusing the detection that carried it. A schema `enum` would
/// promise the members are the whole set; this one cannot, so it publishes a scalar.
///
/// **The words are the framework's own fold**, walked by [`folds_to`](crate::name::folds_to): ASCII
/// case and `_`, `-` and a space are ignored, so `dataMatrix`, `DATA_MATRIX` and `data matrix` are
/// one value. The escape carries the MATERIALISED fold, so two producers writing `foo-bar` and
/// `FooBar` for a standard nobody here names are one value, compare equal and hash into one bucket.
///
/// # Apple's TYPE PREFIX is [`from_vision`](Self::from_vision)'s business and not the door's
///
/// A producer of barcodes hands over `VNBarcodeSymbologyQR`, and the plain door CARRIES that whole
/// string rather than reading `qr` out of it. Removing the prefix is one adapter's job and it has
/// its own entry, because the fold is a rule about SPELLINGS and a vendor namespace is not one: the
/// fold is the framework's, shared by every open vocabulary in the workspace, and a strip word there
/// would be a second rule that only one house ever used.
///
/// # The roster's own shape
///
/// **The CHECKSUM variants are separate members and not a flag**, which is the source's own shape
/// and the right one: `code39` and `code39_checksum` are two ways a decoder was configured, and a
/// row recording only `code39` would lose whether the check digit was verified.
///
/// **`code93i` is not a typo.** It is Code 93i, the extended variant, and Vision spells it with the
/// lower-case letter attached.
///
/// # Examples
///
/// ```
/// use ingraph::Symbology;
///
/// assert_eq!(Symbology::new("qr"), Symbology::Qr);
/// assert_eq!(Symbology::new("DATA_MATRIX"), Symbology::DataMatrix);
/// assert_eq!(Symbology::new("data matrix"), Symbology::DataMatrix);
///
/// // …and a standard this roster does not name is carried rather than refused.
/// let unknown = Symbology::new("Han Xin");
/// assert!(unknown.is_other());
/// assert_eq!(unknown.as_str(), "hanxin");
/// ```
///
/// [`VNBarcodeSymbology`]: https://developer.apple.com/documentation/vision/vnbarcodesymbology
/// The roster, paired with the canonical slug each member is written as.
///
/// The words are stated ONCE, here, and every door reads them: [`Symbology::new`] walks this table
/// under the fold and [`Symbology::as_str`] indexes it. A slug spelled twice would be a slug free to
/// drift, which is the whole reason the derive that would have generated these keeps one table too.
const ROSTER: & = &;
/// The remainder of `raw` after [`VISION_PREFIX`], under the door's own fold — or `raw` itself where
/// it does not begin with one, or is nothing but one.
///
/// The returned index sits immediately after an ASCII byte the prefix matched, so it is always a
/// character boundary; `get` is used rather than an index anyway, because a boundary this function
/// establishes is a claim and not a proof.
/// The canonical slug, and nothing else — no quotes, no wrapper, no type name.
/// The slug IN QUOTES, which is what a `Debug` of a one-word vocabulary is FOR: the variant path
/// around it says nothing a reader of a failing assertion wants.
/// The parse, forwarded to this type's own door — and INFALLIBLE, the open escape being what makes
/// every string a symbology.
/// **ONE column**, which is the default — stated rather than inherited, because the composite in
/// this house that holds one reads its width off this row.
/// **One leaf, and it is the value** — ONE column, so there is no sequence to permute.
// A symbology is the same as a symbology when its canonical slug is — the escape's word is
// materialised and folded at construction, so two producers spelling one standard differently
// already compare equal here.
column_eq!
/// **THE STORED WORD is text's**, in every dialect that has one.
///
/// Delegated to [`String`] rather than named, for the reason the bind below is: a symbology IS its
/// canonical slug, so the column is a text column and the dialect's own word for one is the only
/// answer. The delegation carries the ADMISSION with it — a symbology is declarable exactly where
/// text is, which is everywhere.
/// **ONE BIND OUT** — the canonical slug, as text.
///
/// An OWNED [`String`] rather than the borrowed `&str` the value already holds, for the reason every
/// text citizen in [`primitives`](crate::primitives) pays at this seat: `push_bind` requires its
/// value to outlive the builder's `'args`, which this trait's signature leaves unrelated to `&self`.
/// **AND THE WORD BACK IN**, through the door — and it CANNOT FAIL.
///
/// This is where an open vocabulary parts company with [`Label`](super::Label) one file over: that
/// type refuses an empty stored word because a label that is nothing is not a label, and this one
/// refuses nothing at all because a symbology this crate has never heard of is still a symbology.
/// A stored word the roster does not name comes back through the escape, CANONICALISED rather than
/// wrapped, so a hand-written `UPDATE` writing `DATA-MATRIX` reads back as the named member.
/// **THE KEYSET POSITION**: the canonical slug's UTF-8 bytes, which is what a `TEXT` column orders
/// by and what the [`Ord`] above walks.
///
/// The read CANONICALISES rather than validating — a cursor is a string a CLIENT hands back, and
/// this vocabulary has no spelling to refuse it for. What it can still refuse is bytes that are not
/// UTF-8 at all, which is the one way a forged position fails here.
/// **THE ADMISSION** — a symbology is one element of one.
///
/// `Vec<Symbology>` is what a frame carrying several codes read under several standards holds, once
/// a caller wants the standards without the payloads.
/// **THE DOCUMENT'S FORM: a BSON `String` holding the canonical slug** — the same text the `TEXT`
/// column above binds.
///
/// As with every other row of its kind here, this is the FILTER OPERAND's form and not a serde row.
/// **THE READ: the same slug, back through the door** — [`MongoCarrier`](crate::MongoCarrier)'s
/// mirror.
///
/// It carries NO range refusal, and the absence is this vocabulary's openness: a document holding a
/// `string` naming no member of the roster is an escape rather than an error. What survives is the
/// TYPE refusal — a document holding a number where a symbology belongs is still wrong, and still
/// says which BSON type arrived.
/// **THE VOCABULARY READING** — `eq`, `ne`, `in` and `notIn`, and nothing else.
///
/// It is the ENUM filter and not the text one, and the difference is what the word IS. A
/// [`Label`](super::Label) is free text from a model's own roster, so `contains: "retriever"` is a
/// real question about a real family of words. A symbology is a STANDARD, so the affix family would
/// answer questions about SPELLING: `contains: "qr"` matches `micro_qr`, which is true of the two
/// slugs and false of the two standards.
///
/// The ORDERING slots go with them, and for the same reason: alphabetical order over
/// `aztec < code128 < qr` is an order over the words rather than over the standards, and no caller
/// asks for the barcodes between two spellings. That is the ONE place this house's open vocabulary
/// parts company with the codec citizens, which take the wide scalar kind because a codec column IS
/// paged over.
///
/// **`in` is where the escape earns its keep.** A client asking about every 2D matrix writes
/// `{ in: ["qr", "micro_qr", "aztec", "data_matrix"] }`, and a client routing the standards it has
/// never met writes `{ notIn: [ … the roster … ] }` — which is a question no closed enum could
/// express, there being nothing outside it.
/// The interpretation a [`Symbology`] field is read under — the ENUM family's, which is what puts
/// `Option<Symbology>` on the `isNull` road.
/// **A COLLECTION of symbologies is asked as a LIST** — the vocabulary's own operators lifted, which
/// is what an unordered set of words earns where a scored finding does not.