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
//! [`Rate`]'s wire faces: the OBJECT a client reads and the SCALAR one whole-value operand crosses
//! on. The INPUT OBJECT the three facets are published as is DECLARED rather than written — see
//! [`RateFilter`](super::RateFilter), whose field list is the whole of it.
//!
//! ```text
//! type Rate { input RateFilter {
//! numerator: Int! eq: RateOperand ─┐
//! denominator: Int! ne: RateOperand │ VALUE
//! name: String in: [RateOperand!] │
//! text: String! notIn: [RateOperand!] ─┘
//! hz: Int startsWith: String ─┐
//! perSecond: Float! endsWith: String │ RENDER
//! timebase: Timebase contains: String ─┘
//! } numerator: I32Filter ─┐ COMPONENT
//! denominator: …Filter ─┘
//! scalar RateOperand }
//! ```
//!
//! # WIDE IN, STRICT OUT — three shapes, and no bare number
//!
//! [`RateOperand`] reads the structure `{ numerator: 30000, denominator: 1001 }`, the text
//! `"30000/1001"`, and the roster NAME `"FPS_29_97"` (case-folded, as `mediatime`'s own `from_name`
//! folds it). What comes back out is always the canonical text, so a value read from this schema and
//! sent back to it is the same value by the shortest route.
//!
//! **A bare number is refused, and not for the timebase's reason.** A timebase refuses `30` because
//! it reads three ways; a rate has no such trap, `30/1` and "thirty a second" being one rational.
//! It is refused because the next thing a client writes is `29.97`, and that is a DIFFERENT RATE
//! from the `30000/1001` they mean — so a door taking integers would have to take the decimal beside
//! them or explain why not, and taking it means guessing at a roster entry or storing a rate no
//! stream declares. Refusing both is one rule. See [`RateFilter`](super::RateFilter), where the
//! whole argument is.
//!
//! # The fan publishes two stored fields and five readings of them
//!
//! `numerator` and `denominator` are the value, as DECLARED. The other five are derived and each
//! says something the pair does not say on its own:
//!
//! | field | exact? | says |
//! |---|---|---|
//! | `name` | exact | the roster entry this rate equals, or null off-roster |
//! | `text` | exact | the canonical `num/den` — the form an operand takes |
//! | `hz` | EXACT | the whole-number reading, or null where the rate is fractional |
//! | `perSecond` | lossy | the same rate as a double, for every rate |
//! | `timebase` | exact | the RECIPROCAL reading, as a whole [`Timebase`] — null for a zero rate |
//!
//! `hz` and `perSecond` are not two names for one number. `hz` is `mediatime`'s own integral
//! constructor read backwards and is null for 29.97; `perSecond` is the division and is total. A
//! client asking "is this exactly 30" reads the first and gets a yes or a null; one asking "how fast"
//! reads the second and gets a number it can format.
//!
//! `timebase` is the one field that publishes another citizen, and it is why a client never has to
//! know that `to_timebase` swaps the pair — the reciprocal arrives with its own name, its own fan
//! and its own roster entry.
//!
//! # Why the OBJECT is still written where the type is DECLARED
//!
//! [`Rate`] carries `#[crate::fields(…)]` without the `graphql` word, and the word is absent for a
//! reason the compiler states rather than for a preference taken here. The face is ALL OR NOTHING —
//! a fragment's `#[Object]` is one the expansion writes, and a second `#[Object] impl Rate` beside
//! it is two impls of one trait for one type — so activating it means the emission must publish all
//! seven fields below. It cannot publish even the two DECLARED ones:
//!
//! - **`NonZeroI32` answers no `ToGraphqlOutput`.** The emitted object crosses every field through
//! this framework's own output map, and the denominator's type has no row in it — measured as
//! `E0277` at the declaration. async-graphql's own map does have one, which is what the hand
//! resolver below reaches and why `denominator: Int!` is spellable at all here.
//! - **The five DERIVED readings have one door and it does not reach them.** `delegate(fn …)` is the
//! only seat that puts a field on a fragment's object beyond its columns, and in REWRITE mode the
//! method it emits forwards to `(&self.0).m()` — the WRAPPED value's method. `per_second`, the
//! exact `hz` rule and the reciprocal-as-[`Timebase`] are this crate's own readings of
//! `mediatime`'s pair, so each is `E0599` on `mediatime::Rate` and the two that also name a method
//! this newtype already has are `E0592` beside it. `name` fails one step further out:
//! `&'static str` answers no `ToGraphqlOutput` either.
use crateToGraphqlOutput;
use ;
use NonZeroI32;
use mediatime as mt;
use ;
/// A rate as a filter operand: the structure `{ numerator, denominator }`, the text `"30000/1001"`,
/// or a well-known name such as `"FPS_29_97"`.
///
/// Written back as the canonical text, whichever of the three it arrived as.
/// The three arms: a structure, the canonical text, and a roster name.
/// The STRUCTURED arm: both halves, required, and no other key.
///
/// Strict about extra keys because a filter operand is not a place to be forgiving — a typo that a
/// lenient reader turns into `30000/1` returns the wrong rows rather than an error.
/// The two STRING arms, told apart by the slash.
///
/// The slash decides rather than a try-and-fall-back, and that is what keeps each arm's error its
/// own: `"30000 / 1001"` hears that a rate is spelled `num/den` — the rational parser's own refusal,
/// naming the rule it broke — where a fall-back would report that it is not a well-known name, which
/// is true and useless. No rate name contains a slash, so the split is total.
///
/// The two ROSTERS are disjoint on purpose, which this arm inherits: `"MPEG_90K"` is not a rate and
/// `"FPS_24"` is not a timebase, and each door refuses the other's names. A door that read both
/// would silently answer `1/24` where `24/1` was written.
/// The OUTPUT row: a rate is returned as ITSELF, by reference, through the object below.
/// A frame or sample rate: the rational `numerator / denominator` events per second that the stream
/// declares.
// The FILTER's wire face is not here, and that is the point: `RateFilter` carries
// `#[ingraph(composed)]`, so its nine slots are read off the struct's own field list and the
// registration, the parse and the render are emitted from that one table. What this module still
// owns is the OPERAND — the scalar those slots register, whose grammar is `mediatime`'s and is no
// derive's business.