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
//! The codec house's wire faces, behind the `async-graphql` feature.
//!
//! Every codec type crosses as a SCALAR and as the SAME scalar in both seats — 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, because
//! neither is publishing an object a scalar of the same name would collide with.
//!
//! ```text
//! scalar VideoCodec
//! scalar AudioCodec
//! scalar SubtitleCodec
//! ```
//!
//! # WIDE IN, STRICT OUT — and here the wide half is as wide as it goes
//!
//! A door reads a JSON string and hands it to the type's own `new`, so the spellings it admits are
//! exactly the ones that type documents. What this layer adds is the JSON shape, and for this house
//! that is the ONLY refusal there is: the vocabulary is open, so every string names a codec and the
//! door turns none of them away.
//!
//! That makes [`is_valid`](async_graphql::ScalarType::is_valid) a question about the JSON kind
//! alone, and it is written that way rather than as a `new(…).is_ok()` that could only ever answer
//! `true`. The subtag house shares its validator with its parser so a query that validates is one
//! that parses; the same property holds here for the narrower reason that there is nothing to
//! disagree about.
//!
//! **A NUMBER is refused**, which is worth a sentence because a codec name can look like one: `012v`
//! is a video codec and `Other` would hold any digits at all. A JSON number has no leading zeros, so
//! `012v`'s own spelling could not survive the round trip as one — and admitting bare digits while
//! refusing `012v` would be a door whose grammar depended on which codec a client asked about.
//!
//! # The name is SPELLED
//!
//! `#[Scalar(name = …)]` on every one of the three, as the subtag doors and `SoundEventCode` both
//! take it: a wire name is a schema commitment, and a Rust rename is not a schema change.
use ;
use ;
/// Generate one codec type's SCALAR DOOR — the JSON shape, and nothing about the codec vocabulary.
///
/// The three bodies are the same three bodies: read a string, hand it to the type's own `new`,
/// refuse everything else, and write back the canonical slug. Writing them out three times would be
/// three chances for one of them to admit a JSON shape the others do not.
///
/// **The DESCRIPTION is passed in and not generated.** async-graphql publishes the doc comment as
/// the scalar's SDL description, so it is the sentence a client reads to learn what the operand is
/// — the one part of a door that cannot be shared.
codec_scalar!
codec_scalar!
codec_scalar!