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
//! [`BarcodePayloadKind`]: what KIND OF THING a barcode's decoded payload names — ten named members
//! and one escape.
use fmt;
use Utf8Bytes;
use crate::;
/// **THE KIND OF THING a barcode's decoded payload names** — ten named kinds, plus an escape for a
/// word this vocabulary does not name.
///
/// ```text
/// GENERIC url text
/// STRUCTURED wifi contact email phone sms geo calendar
/// SYMBOLOGY-DECIDED product
/// ```
///
/// # It is a VOCABULARY and not a CLASSIFIER
///
/// This type names WHAT a payload is, not how to decide it. Reading `WIFI:S:home;;` off a QR code
/// and turning that string into [`Wifi`](Self::Wifi) is a classifier's job, and it is the app's
/// barcode node's rather than this crate's — [`Symbology`](super::Symbology) says how the bars were
/// read and this type says what the payload MEANS, so classifying one is a function of BOTH: a 1-D
/// product symbology names a [`Product`](Self::Product) whatever its digits say, and a 2-D
/// symbology's payload has to be read to tell a [`Wifi`](Self::Wifi) credential from a bare
/// [`Url`](Self::Url). This crate carries neither reading. It only names where one lands.
///
/// # The conventional prefixes, for the classifier that reads them
///
/// Stated here once, for the caller that has to know them and not for this type, which parses none
/// of them — the door below reads a KIND's own name (`"wifi"`, `"geo"`, …), never a payload:
///
/// | kind | conventional payload prefix |
/// |---|---|
/// | [`Wifi`](Self::Wifi) | `WIFI:` |
/// | [`Contact`](Self::Contact) | `BEGIN:VCARD` or `MECARD:` |
/// | [`Email`](Self::Email) | `mailto:` |
/// | [`Phone`](Self::Phone) | `tel:` |
/// | [`Sms`](Self::Sms) | `sms:` or `SMSTO:` |
/// | [`Geo`](Self::Geo) | `geo:` |
/// | [`Calendar`](Self::Calendar) | `BEGIN:VEVENT` |
/// | [`Url`](Self::Url) | any URL scheme |
/// | [`Product`](Self::Product) | none — the SYMBOLOGY says so: every 1-D product symbology |
/// | [`Text`](Self::Text) | none — the payload matched no structured form above |
///
/// # It is DOMAIN-NEUTRAL, on [`Symbology`](super::Symbology)'s own precedent
///
/// A barcode is read off a photograph, a scanned invoice, a PDF page and a shipping label, and what
/// its payload MEANS does not depend on which of those it was read from — the same argument that
/// sent [`Symbology`] here one member up applies unchanged to what its payload names.
///
/// # OPEN, and the escape is why the wire face is a SCALAR
///
/// The roster is not one vendor's enum — no single specification lists "the" barcode payload kinds —
/// so it is a HAND-CURATED set: the two loosest kinds a payload can be, the seven structured shapes a
/// producer conventionally prefixes, and the one kind a SYMBOLOGY decides rather than a payload. A
/// kind this roster does not name is exactly as survivable as a standard [`Symbology`] does not name:
/// carried through the escape rather than refused. 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 `Wi-Fi`, `WIFI` and `wifi` are one value. The escape
/// carries the MATERIALISED fold, so two producers writing `boarding-pass` and `BoardingPass` for a
/// kind nobody here names are one value, compare equal and hash into one bucket.
///
/// # Examples
///
/// ```
/// use ingraph::BarcodePayloadKind;
///
/// assert_eq!(BarcodePayloadKind::new("wifi"), BarcodePayloadKind::Wifi);
/// assert_eq!(BarcodePayloadKind::new("WIFI"), BarcodePayloadKind::Wifi);
/// assert_eq!(BarcodePayloadKind::new("Wi Fi"), BarcodePayloadKind::Wifi);
///
/// // …and a kind this roster does not name is carried rather than refused.
/// let unknown = BarcodePayloadKind::new("Boarding Pass");
/// assert!(unknown.is_other());
/// assert_eq!(unknown.as_str(), "boardingpass");
/// ```
/// The roster, paired with the canonical slug each member is written as.
///
/// The words are stated ONCE, here, and every door reads them: [`BarcodePayloadKind::new`] walks
/// this table under the fold and [`BarcodePayloadKind::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 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 payload kind.
/// **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.
// The SAMENESS row beside the width — the face an emitted row and an emitted page cursor fold in
// place of the `PartialEq` they used to derive. Two payload kinds are one column value when they
// are one word, which is what an open vocabulary's own `PartialEq` says.
column_eq!
/// **One leaf, and it is the value** — ONE column, so there is no sequence to permute.
/// **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 payload kind 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 payload kind 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): 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 kind this crate has never heard of is still a payload kind. A stored word the
/// roster does not name comes back through the escape, CANONICALISED rather than wrapped, so a
/// hand-written `UPDATE` writing `BOARDING-PASS` reads back under its folded word.
/// **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 payload kind is one element of one.
///
/// `Vec<BarcodePayloadKind>` is what a page carrying several codes classified under several kinds
/// holds, once a caller wants the kinds 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 payload kind 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 payload kind is a CLASSIFICATION, so the affix
/// family would answer a question about SPELLING rather than about which kind a payload was read
/// as — the same reasoning [`Symbology`](super::Symbology) makes for its own roster.
///
/// The ORDERING slots go with them, and for the same reason: alphabetical order over
/// `calendar < contact < …` is an order over the words rather than over the kinds, and no caller asks
/// for the payloads between two spellings.
///
/// **`in` is where the escape earns its keep.** A client asking about every structured payload writes
/// `{ in: ["wifi", "contact", "email", "phone", "sms", "geo", "calendar"] }`, and a client routing the
/// kinds 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 [`BarcodePayloadKind`] field is read under — the ENUM family's, which is
/// what puts `Option<BarcodePayloadKind>` on the `isNull` road.
/// **A COLLECTION of payload kinds 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.