/rust/registry/src/index.crates.io-1949cf8c6b5b557f/async-graphql-value-7.0.17/src/serializer.rs
Line | Count | Source |
1 | | use std::{error::Error, fmt}; |
2 | | |
3 | | use indexmap::IndexMap; |
4 | | use serde::{ |
5 | | Serialize, |
6 | | ser::{self, Impossible}, |
7 | | }; |
8 | | |
9 | | use crate::{ConstValue, Name, Number}; |
10 | | |
11 | | /// This type represents errors that can occur when serializing. |
12 | | #[derive(Debug)] |
13 | | pub struct SerializerError(String); |
14 | | |
15 | | impl fmt::Display for SerializerError { |
16 | 0 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
17 | 0 | match *self { |
18 | 0 | SerializerError(ref s) => fmt.write_str(s), |
19 | | } |
20 | 0 | } |
21 | | } |
22 | | |
23 | | impl Error for SerializerError { |
24 | 0 | fn description(&self) -> &str { |
25 | 0 | "ConstValue serializer error" |
26 | 0 | } |
27 | | } |
28 | | |
29 | | impl ser::Error for SerializerError { |
30 | 0 | fn custom<T: fmt::Display>(msg: T) -> SerializerError { |
31 | 0 | SerializerError(msg.to_string()) |
32 | 0 | } |
33 | | } |
34 | | |
35 | | /// Convert a `T` into `ConstValue` which is an enum that can represent any |
36 | | /// valid GraphQL data. |
37 | | #[inline] |
38 | 0 | pub fn to_value<T: ser::Serialize>(value: T) -> Result<ConstValue, SerializerError> { |
39 | 0 | value.serialize(Serializer) |
40 | 0 | } Unexecuted instantiation: async_graphql_value::serializer::to_value::<&usize> Unexecuted instantiation: async_graphql_value::serializer::to_value::<_> |
41 | | |
42 | | struct Serializer; |
43 | | |
44 | | impl ser::Serializer for Serializer { |
45 | | type Ok = ConstValue; |
46 | | type Error = SerializerError; |
47 | | type SerializeSeq = SerializeSeq; |
48 | | type SerializeTuple = SerializeTuple; |
49 | | type SerializeTupleStruct = SerializeTupleStruct; |
50 | | type SerializeTupleVariant = SerializeTupleVariant; |
51 | | type SerializeMap = SerializeMap; |
52 | | type SerializeStruct = SerializeStruct; |
53 | | type SerializeStructVariant = SerializeStructVariant; |
54 | | |
55 | | #[inline] |
56 | 0 | fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error> { |
57 | 0 | Ok(ConstValue::Boolean(v)) |
58 | 0 | } |
59 | | |
60 | | #[inline] |
61 | 0 | fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error> { |
62 | 0 | Ok(ConstValue::Number(v.into())) |
63 | 0 | } |
64 | | |
65 | | #[inline] |
66 | 0 | fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error> { |
67 | 0 | Ok(ConstValue::Number(v.into())) |
68 | 0 | } |
69 | | |
70 | | #[inline] |
71 | 0 | fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error> { |
72 | 0 | Ok(ConstValue::Number(v.into())) |
73 | 0 | } |
74 | | |
75 | | #[inline] |
76 | 0 | fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error> { |
77 | 0 | Ok(ConstValue::Number(v.into())) |
78 | 0 | } |
79 | | |
80 | | #[inline] |
81 | 0 | fn serialize_u8(self, v: u8) -> Result<Self::Ok, Self::Error> { |
82 | 0 | Ok(ConstValue::Number(v.into())) |
83 | 0 | } |
84 | | |
85 | | #[inline] |
86 | 0 | fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error> { |
87 | 0 | Ok(ConstValue::Number(v.into())) |
88 | 0 | } |
89 | | |
90 | | #[inline] |
91 | 0 | fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error> { |
92 | 0 | Ok(ConstValue::Number(v.into())) |
93 | 0 | } |
94 | | |
95 | | #[inline] |
96 | 0 | fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error> { |
97 | 0 | Ok(ConstValue::Number(v.into())) |
98 | 0 | } Unexecuted instantiation: <async_graphql_value::serializer::Serializer as serde_core::ser::Serializer>::serialize_u64 Unexecuted instantiation: <async_graphql_value::serializer::Serializer as serde_core::ser::Serializer>::serialize_u64 |
99 | | |
100 | | #[inline] |
101 | 0 | fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error> { |
102 | 0 | self.serialize_f64(v as f64) |
103 | 0 | } |
104 | | |
105 | | #[inline] |
106 | 0 | fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error> { |
107 | 0 | match Number::from_f64(v) { |
108 | 0 | Some(v) => Ok(ConstValue::Number(v)), |
109 | 0 | None => Ok(ConstValue::Null), |
110 | | } |
111 | 0 | } |
112 | | |
113 | | #[inline] |
114 | 0 | fn serialize_char(self, _v: char) -> Result<Self::Ok, Self::Error> { |
115 | 0 | Err(SerializerError("char is not supported.".to_string())) |
116 | 0 | } |
117 | | |
118 | | #[inline] |
119 | 0 | fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error> { |
120 | 0 | Ok(ConstValue::String(v.to_string())) |
121 | 0 | } |
122 | | |
123 | | #[inline] |
124 | 0 | fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error> { |
125 | 0 | Ok(ConstValue::Binary(v.to_vec().into())) |
126 | 0 | } |
127 | | |
128 | | #[inline] |
129 | 0 | fn serialize_none(self) -> Result<Self::Ok, Self::Error> { |
130 | 0 | Ok(ConstValue::Null) |
131 | 0 | } |
132 | | |
133 | | #[inline] |
134 | 0 | fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error> |
135 | 0 | where |
136 | 0 | T: ser::Serialize + ?Sized, |
137 | | { |
138 | 0 | value.serialize(self) |
139 | 0 | } |
140 | | |
141 | | #[inline] |
142 | 0 | fn serialize_unit(self) -> Result<Self::Ok, Self::Error> { |
143 | 0 | Ok(ConstValue::Null) |
144 | 0 | } |
145 | | |
146 | | #[inline] |
147 | 0 | fn serialize_unit_struct(self, _name: &'static str) -> Result<Self::Ok, Self::Error> { |
148 | 0 | Ok(ConstValue::Null) |
149 | 0 | } |
150 | | |
151 | | #[inline] |
152 | 0 | fn serialize_unit_variant( |
153 | 0 | self, |
154 | 0 | _name: &'static str, |
155 | 0 | _variant_index: u32, |
156 | 0 | variant: &'static str, |
157 | 0 | ) -> Result<Self::Ok, Self::Error> { |
158 | 0 | Ok(ConstValue::String(variant.to_string())) |
159 | 0 | } |
160 | | |
161 | | #[inline] |
162 | 0 | fn serialize_newtype_struct<T>( |
163 | 0 | self, |
164 | 0 | _name: &'static str, |
165 | 0 | value: &T, |
166 | 0 | ) -> Result<Self::Ok, Self::Error> |
167 | 0 | where |
168 | 0 | T: ser::Serialize + ?Sized, |
169 | | { |
170 | 0 | value.serialize(self) |
171 | 0 | } |
172 | | |
173 | | #[inline] |
174 | 0 | fn serialize_newtype_variant<T>( |
175 | 0 | self, |
176 | 0 | _name: &'static str, |
177 | 0 | _variant_index: u32, |
178 | 0 | variant: &'static str, |
179 | 0 | value: &T, |
180 | 0 | ) -> Result<Self::Ok, Self::Error> |
181 | 0 | where |
182 | 0 | T: ser::Serialize + ?Sized, |
183 | | { |
184 | 0 | value.serialize(self).map(|v| { |
185 | 0 | let mut map = IndexMap::new(); |
186 | 0 | map.insert(Name::new(variant), v); |
187 | 0 | ConstValue::Object(map) |
188 | 0 | }) |
189 | 0 | } |
190 | | |
191 | | #[inline] |
192 | 0 | fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> { |
193 | 0 | Ok(SerializeSeq(vec![])) |
194 | 0 | } |
195 | | |
196 | | #[inline] |
197 | 0 | fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple, Self::Error> { |
198 | 0 | Ok(SerializeTuple(vec![])) |
199 | 0 | } |
200 | | |
201 | | #[inline] |
202 | 0 | fn serialize_tuple_struct( |
203 | 0 | self, |
204 | 0 | _name: &'static str, |
205 | 0 | _len: usize, |
206 | 0 | ) -> Result<Self::SerializeTupleStruct, Self::Error> { |
207 | 0 | Ok(SerializeTupleStruct(vec![])) |
208 | 0 | } |
209 | | |
210 | | #[inline] |
211 | 0 | fn serialize_tuple_variant( |
212 | 0 | self, |
213 | 0 | _name: &'static str, |
214 | 0 | _variant_index: u32, |
215 | 0 | variant: &'static str, |
216 | 0 | len: usize, |
217 | 0 | ) -> Result<Self::SerializeTupleVariant, Self::Error> { |
218 | 0 | Ok(SerializeTupleVariant( |
219 | 0 | Name::new(variant), |
220 | 0 | Vec::with_capacity(len), |
221 | 0 | )) |
222 | 0 | } |
223 | | |
224 | | #[inline] |
225 | 0 | fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap, Self::Error> { |
226 | 0 | Ok(SerializeMap { |
227 | 0 | map: IndexMap::new(), |
228 | 0 | key: None, |
229 | 0 | }) |
230 | 0 | } |
231 | | |
232 | | #[inline] |
233 | 0 | fn serialize_struct( |
234 | 0 | self, |
235 | 0 | _name: &'static str, |
236 | 0 | _len: usize, |
237 | 0 | ) -> Result<Self::SerializeStruct, Self::Error> { |
238 | 0 | Ok(SerializeStruct(IndexMap::new())) |
239 | 0 | } |
240 | | |
241 | | #[inline] |
242 | 0 | fn serialize_struct_variant( |
243 | 0 | self, |
244 | 0 | _name: &'static str, |
245 | 0 | _variant_index: u32, |
246 | 0 | variant: &'static str, |
247 | 0 | _len: usize, |
248 | 0 | ) -> Result<Self::SerializeStructVariant, Self::Error> { |
249 | 0 | Ok(SerializeStructVariant(Name::new(variant), IndexMap::new())) |
250 | 0 | } |
251 | | |
252 | | #[inline] |
253 | 0 | fn is_human_readable(&self) -> bool { |
254 | 0 | true |
255 | 0 | } |
256 | | } |
257 | | |
258 | | struct SerializeSeq(Vec<ConstValue>); |
259 | | |
260 | | impl ser::SerializeSeq for SerializeSeq { |
261 | | type Ok = ConstValue; |
262 | | type Error = SerializerError; |
263 | | |
264 | | #[inline] |
265 | 0 | fn serialize_element<T>(&mut self, value: &T) -> Result<(), Self::Error> |
266 | 0 | where |
267 | 0 | T: ser::Serialize + ?Sized, |
268 | | { |
269 | 0 | let value = value.serialize(Serializer)?; |
270 | 0 | self.0.push(value); |
271 | 0 | Ok(()) |
272 | 0 | } |
273 | | |
274 | | #[inline] |
275 | 0 | fn end(self) -> Result<Self::Ok, Self::Error> { |
276 | 0 | Ok(ConstValue::List(self.0)) |
277 | 0 | } |
278 | | } |
279 | | |
280 | | struct SerializeTuple(Vec<ConstValue>); |
281 | | |
282 | | impl ser::SerializeTuple for SerializeTuple { |
283 | | type Ok = ConstValue; |
284 | | type Error = SerializerError; |
285 | | |
286 | | #[inline] |
287 | 0 | fn serialize_element<T>(&mut self, value: &T) -> Result<(), Self::Error> |
288 | 0 | where |
289 | 0 | T: ser::Serialize + ?Sized, |
290 | | { |
291 | 0 | let value = value.serialize(Serializer)?; |
292 | 0 | self.0.push(value); |
293 | 0 | Ok(()) |
294 | 0 | } |
295 | | |
296 | | #[inline] |
297 | 0 | fn end(self) -> Result<Self::Ok, Self::Error> { |
298 | 0 | Ok(ConstValue::List(self.0)) |
299 | 0 | } |
300 | | } |
301 | | |
302 | | struct SerializeTupleStruct(Vec<ConstValue>); |
303 | | |
304 | | impl ser::SerializeTupleStruct for SerializeTupleStruct { |
305 | | type Ok = ConstValue; |
306 | | type Error = SerializerError; |
307 | | |
308 | | #[inline] |
309 | 0 | fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error> |
310 | 0 | where |
311 | 0 | T: ser::Serialize + ?Sized, |
312 | | { |
313 | 0 | let value = value.serialize(Serializer)?; |
314 | 0 | self.0.push(value); |
315 | 0 | Ok(()) |
316 | 0 | } |
317 | | |
318 | | #[inline] |
319 | 0 | fn end(self) -> Result<Self::Ok, Self::Error> { |
320 | 0 | Ok(ConstValue::List(self.0)) |
321 | 0 | } |
322 | | } |
323 | | |
324 | | struct SerializeTupleVariant(Name, Vec<ConstValue>); |
325 | | |
326 | | impl ser::SerializeTupleVariant for SerializeTupleVariant { |
327 | | type Ok = ConstValue; |
328 | | type Error = SerializerError; |
329 | | |
330 | | #[inline] |
331 | 0 | fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error> |
332 | 0 | where |
333 | 0 | T: ser::Serialize + ?Sized, |
334 | | { |
335 | 0 | let value = value.serialize(Serializer)?; |
336 | 0 | self.1.push(value); |
337 | 0 | Ok(()) |
338 | 0 | } |
339 | | |
340 | | #[inline] |
341 | 0 | fn end(self) -> Result<Self::Ok, Self::Error> { |
342 | 0 | let mut map = IndexMap::new(); |
343 | 0 | map.insert(self.0, ConstValue::List(self.1)); |
344 | 0 | Ok(ConstValue::Object(map)) |
345 | 0 | } |
346 | | } |
347 | | |
348 | | struct SerializeMap { |
349 | | map: IndexMap<Name, ConstValue>, |
350 | | key: Option<Name>, |
351 | | } |
352 | | |
353 | | impl ser::SerializeMap for SerializeMap { |
354 | | type Ok = ConstValue; |
355 | | type Error = SerializerError; |
356 | | |
357 | | #[inline] |
358 | 0 | fn serialize_key<T>(&mut self, key: &T) -> Result<(), Self::Error> |
359 | 0 | where |
360 | 0 | T: ser::Serialize + ?Sized, |
361 | | { |
362 | 0 | let key = key.serialize(MapKeySerializer)?; |
363 | 0 | self.key = Some(key); |
364 | 0 | Ok(()) |
365 | 0 | } |
366 | | |
367 | | #[inline] |
368 | 0 | fn serialize_value<T>(&mut self, value: &T) -> Result<(), Self::Error> |
369 | 0 | where |
370 | 0 | T: ser::Serialize + ?Sized, |
371 | | { |
372 | 0 | let value = value.serialize(Serializer)?; |
373 | 0 | self.map.insert(self.key.take().unwrap(), value); |
374 | 0 | Ok(()) |
375 | 0 | } |
376 | | |
377 | | #[inline] |
378 | 0 | fn end(self) -> Result<Self::Ok, Self::Error> { |
379 | 0 | Ok(ConstValue::Object(self.map)) |
380 | 0 | } |
381 | | } |
382 | | |
383 | | struct SerializeStruct(IndexMap<Name, ConstValue>); |
384 | | |
385 | | impl ser::SerializeStruct for SerializeStruct { |
386 | | type Ok = ConstValue; |
387 | | type Error = SerializerError; |
388 | | |
389 | | #[inline] |
390 | 0 | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error> |
391 | 0 | where |
392 | 0 | T: ser::Serialize + ?Sized, |
393 | | { |
394 | 0 | let key = Name::new(key); |
395 | 0 | let value = value.serialize(Serializer)?; |
396 | 0 | self.0.insert(key, value); |
397 | 0 | Ok(()) |
398 | 0 | } |
399 | | |
400 | | #[inline] |
401 | 0 | fn end(self) -> Result<Self::Ok, Self::Error> { |
402 | 0 | Ok(ConstValue::Object(self.0)) |
403 | 0 | } |
404 | | } |
405 | | |
406 | | struct SerializeStructVariant(Name, IndexMap<Name, ConstValue>); |
407 | | |
408 | | impl ser::SerializeStructVariant for SerializeStructVariant { |
409 | | type Ok = ConstValue; |
410 | | type Error = SerializerError; |
411 | | |
412 | | #[inline] |
413 | 0 | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error> |
414 | 0 | where |
415 | 0 | T: ser::Serialize + ?Sized, |
416 | | { |
417 | 0 | let key = Name::new(key); |
418 | 0 | let value = value.serialize(Serializer)?; |
419 | 0 | self.1.insert(key, value); |
420 | 0 | Ok(()) |
421 | 0 | } |
422 | | |
423 | | #[inline] |
424 | 0 | fn end(self) -> Result<Self::Ok, Self::Error> { |
425 | 0 | let mut map = IndexMap::new(); |
426 | 0 | map.insert(self.0, ConstValue::Object(self.1)); |
427 | 0 | Ok(ConstValue::Object(map)) |
428 | 0 | } |
429 | | } |
430 | | |
431 | | #[inline] |
432 | 0 | fn key_must_be_a_string() -> SerializerError { |
433 | 0 | SerializerError("Key must be a string".to_string()) |
434 | 0 | } |
435 | | |
436 | | struct MapKeySerializer; |
437 | | |
438 | | impl serde::Serializer for MapKeySerializer { |
439 | | type Ok = Name; |
440 | | type Error = SerializerError; |
441 | | type SerializeSeq = Impossible<Name, SerializerError>; |
442 | | type SerializeTuple = Impossible<Name, SerializerError>; |
443 | | type SerializeTupleStruct = Impossible<Name, SerializerError>; |
444 | | type SerializeTupleVariant = Impossible<Name, SerializerError>; |
445 | | type SerializeMap = Impossible<Name, SerializerError>; |
446 | | type SerializeStruct = Impossible<Name, SerializerError>; |
447 | | type SerializeStructVariant = Impossible<Name, SerializerError>; |
448 | | |
449 | | #[inline] |
450 | 0 | fn serialize_bool(self, _v: bool) -> Result<Self::Ok, Self::Error> { |
451 | 0 | Err(key_must_be_a_string()) |
452 | 0 | } |
453 | | |
454 | | #[inline] |
455 | 0 | fn serialize_i8(self, _v: i8) -> Result<Self::Ok, Self::Error> { |
456 | 0 | Err(key_must_be_a_string()) |
457 | 0 | } |
458 | | |
459 | | #[inline] |
460 | 0 | fn serialize_i16(self, _v: i16) -> Result<Self::Ok, Self::Error> { |
461 | 0 | Err(key_must_be_a_string()) |
462 | 0 | } |
463 | | |
464 | | #[inline] |
465 | 0 | fn serialize_i32(self, _v: i32) -> Result<Self::Ok, Self::Error> { |
466 | 0 | Err(key_must_be_a_string()) |
467 | 0 | } |
468 | | |
469 | | #[inline] |
470 | 0 | fn serialize_i64(self, _v: i64) -> Result<Self::Ok, Self::Error> { |
471 | 0 | Err(key_must_be_a_string()) |
472 | 0 | } |
473 | | |
474 | | #[inline] |
475 | 0 | fn serialize_u8(self, _v: u8) -> Result<Self::Ok, Self::Error> { |
476 | 0 | Err(key_must_be_a_string()) |
477 | 0 | } |
478 | | |
479 | | #[inline] |
480 | 0 | fn serialize_u16(self, _v: u16) -> Result<Self::Ok, Self::Error> { |
481 | 0 | Err(key_must_be_a_string()) |
482 | 0 | } |
483 | | |
484 | | #[inline] |
485 | 0 | fn serialize_u32(self, _v: u32) -> Result<Self::Ok, Self::Error> { |
486 | 0 | Err(key_must_be_a_string()) |
487 | 0 | } |
488 | | |
489 | | #[inline] |
490 | 0 | fn serialize_u64(self, _v: u64) -> Result<Self::Ok, Self::Error> { |
491 | 0 | Err(key_must_be_a_string()) |
492 | 0 | } |
493 | | |
494 | | #[inline] |
495 | 0 | fn serialize_f32(self, _v: f32) -> Result<Self::Ok, Self::Error> { |
496 | 0 | Err(key_must_be_a_string()) |
497 | 0 | } |
498 | | |
499 | | #[inline] |
500 | 0 | fn serialize_f64(self, _v: f64) -> Result<Self::Ok, Self::Error> { |
501 | 0 | Err(key_must_be_a_string()) |
502 | 0 | } |
503 | | |
504 | | #[inline] |
505 | 0 | fn serialize_char(self, _v: char) -> Result<Self::Ok, Self::Error> { |
506 | 0 | Err(key_must_be_a_string()) |
507 | 0 | } |
508 | | |
509 | | #[inline] |
510 | 0 | fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error> { |
511 | 0 | Ok(Name::new(v)) |
512 | 0 | } |
513 | | |
514 | | #[inline] |
515 | 0 | fn serialize_bytes(self, _v: &[u8]) -> Result<Self::Ok, Self::Error> { |
516 | 0 | Err(key_must_be_a_string()) |
517 | 0 | } |
518 | | |
519 | | #[inline] |
520 | 0 | fn serialize_none(self) -> Result<Self::Ok, Self::Error> { |
521 | 0 | Err(key_must_be_a_string()) |
522 | 0 | } |
523 | | |
524 | | #[inline] |
525 | 0 | fn serialize_some<T>(self, _value: &T) -> Result<Self::Ok, Self::Error> |
526 | 0 | where |
527 | 0 | T: Serialize + ?Sized, |
528 | | { |
529 | 0 | Err(key_must_be_a_string()) |
530 | 0 | } |
531 | | |
532 | | #[inline] |
533 | 0 | fn serialize_unit(self) -> Result<Self::Ok, Self::Error> { |
534 | 0 | Err(key_must_be_a_string()) |
535 | 0 | } |
536 | | |
537 | | #[inline] |
538 | 0 | fn serialize_unit_struct(self, _name: &'static str) -> Result<Self::Ok, Self::Error> { |
539 | 0 | Err(key_must_be_a_string()) |
540 | 0 | } |
541 | | |
542 | | #[inline] |
543 | 0 | fn serialize_unit_variant( |
544 | 0 | self, |
545 | 0 | _name: &'static str, |
546 | 0 | _variant_index: u32, |
547 | 0 | variant: &'static str, |
548 | 0 | ) -> Result<Self::Ok, Self::Error> { |
549 | 0 | Ok(Name::new(variant)) |
550 | 0 | } |
551 | | |
552 | | #[inline] |
553 | 0 | fn serialize_newtype_struct<T>( |
554 | 0 | self, |
555 | 0 | _name: &'static str, |
556 | 0 | _value: &T, |
557 | 0 | ) -> Result<Self::Ok, Self::Error> |
558 | 0 | where |
559 | 0 | T: Serialize + ?Sized, |
560 | | { |
561 | 0 | Err(key_must_be_a_string()) |
562 | 0 | } |
563 | | |
564 | | #[inline] |
565 | 0 | fn serialize_newtype_variant<T>( |
566 | 0 | self, |
567 | 0 | _name: &'static str, |
568 | 0 | _variant_index: u32, |
569 | 0 | _variant: &'static str, |
570 | 0 | _value: &T, |
571 | 0 | ) -> Result<Self::Ok, Self::Error> |
572 | 0 | where |
573 | 0 | T: Serialize + ?Sized, |
574 | | { |
575 | 0 | Err(key_must_be_a_string()) |
576 | 0 | } |
577 | | |
578 | | #[inline] |
579 | 0 | fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> { |
580 | 0 | Err(key_must_be_a_string()) |
581 | 0 | } |
582 | | |
583 | | #[inline] |
584 | 0 | fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple, Self::Error> { |
585 | 0 | Err(key_must_be_a_string()) |
586 | 0 | } |
587 | | |
588 | | #[inline] |
589 | 0 | fn serialize_tuple_struct( |
590 | 0 | self, |
591 | 0 | _name: &'static str, |
592 | 0 | _len: usize, |
593 | 0 | ) -> Result<Self::SerializeTupleStruct, Self::Error> { |
594 | 0 | Err(key_must_be_a_string()) |
595 | 0 | } |
596 | | |
597 | | #[inline] |
598 | 0 | fn serialize_tuple_variant( |
599 | 0 | self, |
600 | 0 | _name: &'static str, |
601 | 0 | _variant_index: u32, |
602 | 0 | _variant: &'static str, |
603 | 0 | _len: usize, |
604 | 0 | ) -> Result<Self::SerializeTupleVariant, Self::Error> { |
605 | 0 | Err(key_must_be_a_string()) |
606 | 0 | } |
607 | | |
608 | | #[inline] |
609 | 0 | fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap, Self::Error> { |
610 | 0 | Err(key_must_be_a_string()) |
611 | 0 | } |
612 | | |
613 | | #[inline] |
614 | 0 | fn serialize_struct( |
615 | 0 | self, |
616 | 0 | _name: &'static str, |
617 | 0 | _len: usize, |
618 | 0 | ) -> Result<Self::SerializeStruct, Self::Error> { |
619 | 0 | Err(key_must_be_a_string()) |
620 | 0 | } |
621 | | |
622 | | #[inline] |
623 | 0 | fn serialize_struct_variant( |
624 | 0 | self, |
625 | 0 | _name: &'static str, |
626 | 0 | _variant_index: u32, |
627 | 0 | _variant: &'static str, |
628 | 0 | _len: usize, |
629 | 0 | ) -> Result<Self::SerializeStructVariant, Self::Error> { |
630 | 0 | Err(key_must_be_a_string()) |
631 | 0 | } |
632 | | } |