@@ -26,7 +26,19 @@ pub trait GraphQLVisitor<'de>: Sized {
26
26
& Self :: type_name ( ) ,
27
27
) )
28
28
}
29
- /// Convert a string ID to the target type.
29
+
30
+ /// Visit an integer
31
+ fn visit_u64 < E > ( v : u64 ) -> Result < Self , E >
32
+ where
33
+ E : de:: Error ,
34
+ {
35
+ Err ( de:: Error :: invalid_type (
36
+ de:: Unexpected :: Unsigned ( v) ,
37
+ & Self :: type_name ( ) ,
38
+ ) )
39
+ }
40
+
41
+ /// Visit a borrowed string
30
42
fn visit_str < E > ( v : & str ) -> Result < Self , E >
31
43
where
32
44
E : de:: Error ,
@@ -36,7 +48,19 @@ pub trait GraphQLVisitor<'de>: Sized {
36
48
& Self :: type_name ( ) ,
37
49
) )
38
50
}
39
- /// Produce a default value for a null ID.
51
+
52
+ /// Visit a string
53
+ fn visit_string < E > ( v : String ) -> Result < Self , E >
54
+ where
55
+ E : de:: Error ,
56
+ {
57
+ Err ( de:: Error :: invalid_type (
58
+ de:: Unexpected :: Str ( & v) ,
59
+ & Self :: type_name ( ) ,
60
+ ) )
61
+ }
62
+
63
+ /// Visit a missing optional value
40
64
fn visit_none < E > ( ) -> Result < Self , E >
41
65
where
42
66
E : de:: Error ,
@@ -47,7 +71,7 @@ pub trait GraphQLVisitor<'de>: Sized {
47
71
) )
48
72
}
49
73
50
- /// Produce a default value for a unit.
74
+ /// Visit a null value
51
75
fn visit_unit < E > ( ) -> Result < Self , E >
52
76
where
53
77
E : de:: Error ,
@@ -58,7 +82,7 @@ pub trait GraphQLVisitor<'de>: Sized {
58
82
) )
59
83
}
60
84
61
- /// Convert a sequence of IDs to the target type.
85
+ /// Visit a sequence
62
86
fn visit_seq < A > ( seq : A ) -> Result < Self , A :: Error >
63
87
where
64
88
A : SeqAccess < ' de > ,
@@ -83,12 +107,26 @@ impl GraphQLVisitor<'_> for String {
83
107
Ok ( v. to_string ( ) )
84
108
}
85
109
110
+ fn visit_u64 < E > ( v : u64 ) -> Result < Self , E >
111
+ where
112
+ E : de:: Error ,
113
+ {
114
+ Ok ( v. to_string ( ) )
115
+ }
116
+
86
117
fn visit_str < E > ( v : & str ) -> Result < Self , E >
87
118
where
88
119
E : de:: Error ,
89
120
{
90
121
Ok ( v. to_string ( ) )
91
122
}
123
+
124
+ fn visit_string < E > ( v : String ) -> Result < Self , E >
125
+ where
126
+ E : de:: Error ,
127
+ {
128
+ Ok ( v)
129
+ }
92
130
}
93
131
94
132
impl < ' de , T : GraphQLVisitor < ' de > > GraphQLVisitor < ' de > for Option < T > {
@@ -103,13 +141,27 @@ impl<'de, T: GraphQLVisitor<'de>> GraphQLVisitor<'de> for Option<T> {
103
141
T :: visit_i64 ( v) . map ( Some )
104
142
}
105
143
144
+ fn visit_u64 < E > ( v : u64 ) -> Result < Self , E >
145
+ where
146
+ E : de:: Error ,
147
+ {
148
+ T :: visit_u64 ( v) . map ( Some )
149
+ }
150
+
106
151
fn visit_str < E > ( v : & str ) -> Result < Self , E >
107
152
where
108
153
E : de:: Error ,
109
154
{
110
155
T :: visit_str ( v) . map ( Some )
111
156
}
112
157
158
+ fn visit_string < E > ( v : String ) -> Result < Self , E >
159
+ where
160
+ E : de:: Error ,
161
+ {
162
+ T :: visit_string ( v) . map ( Some )
163
+ }
164
+
113
165
fn visit_none < E > ( ) -> Result < Self , E >
114
166
where
115
167
E : de:: Error ,
@@ -188,7 +240,7 @@ where
188
240
where
189
241
E : de:: Error ,
190
242
{
191
- T :: visit_i64 ( value as i64 )
243
+ T :: visit_u64 ( value)
192
244
}
193
245
194
246
fn visit_str < E > ( self , value : & str ) -> Result < Self :: Value , E >
0 commit comments