Coverage Report

Created: 2026-07-25 06:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/serde-1.0.198/src/private/ser.rs
Line
Count
Source
1
use crate::lib::*;
2
3
use crate::ser::{self, Impossible, Serialize, SerializeMap, SerializeStruct, Serializer};
4
5
#[cfg(any(feature = "std", feature = "alloc"))]
6
use self::content::{
7
    Content, ContentSerializer, SerializeStructVariantAsMapValue, SerializeTupleVariantAsMapValue,
8
};
9
10
/// Used to check that serde(getter) attributes return the expected type.
11
/// Not public API.
12
0
pub fn constrain<T: ?Sized>(t: &T) -> &T {
13
0
    t
14
0
}
Unexecuted instantiation: serde::__private::ser::constrain::<_>
Unexecuted instantiation: serde::__private::ser::constrain::<_>
15
16
/// Not public API.
17
0
pub fn serialize_tagged_newtype<S, T>(
18
0
    serializer: S,
19
0
    type_ident: &'static str,
20
0
    variant_ident: &'static str,
21
0
    tag: &'static str,
22
0
    variant_name: &'static str,
23
0
    value: &T,
24
0
) -> Result<S::Ok, S::Error>
25
0
where
26
0
    S: Serializer,
27
0
    T: Serialize,
28
{
29
0
    value.serialize(TaggedSerializer {
30
0
        type_ident,
31
0
        variant_ident,
32
0
        tag,
33
0
        variant_name,
34
0
        delegate: serializer,
35
0
    })
36
0
}
Unexecuted instantiation: serde::__private::ser::serialize_tagged_newtype::<_, _>
Unexecuted instantiation: serde::__private::ser::serialize_tagged_newtype::<_, _>
37
38
struct TaggedSerializer<S> {
39
    type_ident: &'static str,
40
    variant_ident: &'static str,
41
    tag: &'static str,
42
    variant_name: &'static str,
43
    delegate: S,
44
}
45
46
enum Unsupported {
47
    Boolean,
48
    Integer,
49
    Float,
50
    Char,
51
    String,
52
    ByteArray,
53
    Optional,
54
    #[cfg(any(feature = "std", feature = "alloc"))]
55
    UnitStruct,
56
    Sequence,
57
    Tuple,
58
    TupleStruct,
59
    Enum,
60
}
61
62
impl Display for Unsupported {
63
0
    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
64
0
        match *self {
65
0
            Unsupported::Boolean => formatter.write_str("a boolean"),
66
0
            Unsupported::Integer => formatter.write_str("an integer"),
67
0
            Unsupported::Float => formatter.write_str("a float"),
68
0
            Unsupported::Char => formatter.write_str("a char"),
69
0
            Unsupported::String => formatter.write_str("a string"),
70
0
            Unsupported::ByteArray => formatter.write_str("a byte array"),
71
0
            Unsupported::Optional => formatter.write_str("an optional"),
72
            #[cfg(any(feature = "std", feature = "alloc"))]
73
0
            Unsupported::UnitStruct => formatter.write_str("unit struct"),
74
0
            Unsupported::Sequence => formatter.write_str("a sequence"),
75
0
            Unsupported::Tuple => formatter.write_str("a tuple"),
76
0
            Unsupported::TupleStruct => formatter.write_str("a tuple struct"),
77
0
            Unsupported::Enum => formatter.write_str("an enum"),
78
        }
79
0
    }
Unexecuted instantiation: <serde::__private::ser::Unsupported as core::fmt::Display>::fmt
Unexecuted instantiation: <serde::__private::ser::Unsupported as core::fmt::Display>::fmt
80
}
81
82
impl<S> TaggedSerializer<S>
83
where
84
    S: Serializer,
85
{
86
0
    fn bad_type(self, what: Unsupported) -> S::Error {
87
0
        ser::Error::custom(format_args!(
88
0
            "cannot serialize tagged newtype variant {}::{} containing {}",
89
            self.type_ident, self.variant_ident, what
90
        ))
91
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_>>::bad_type
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_>>::bad_type
92
}
93
94
impl<S> Serializer for TaggedSerializer<S>
95
where
96
    S: Serializer,
97
{
98
    type Ok = S::Ok;
99
    type Error = S::Error;
100
101
    type SerializeSeq = Impossible<S::Ok, S::Error>;
102
    type SerializeTuple = Impossible<S::Ok, S::Error>;
103
    type SerializeTupleStruct = Impossible<S::Ok, S::Error>;
104
    type SerializeMap = S::SerializeMap;
105
    type SerializeStruct = S::SerializeStruct;
106
107
    #[cfg(not(any(feature = "std", feature = "alloc")))]
108
    type SerializeTupleVariant = Impossible<S::Ok, S::Error>;
109
    #[cfg(any(feature = "std", feature = "alloc"))]
110
    type SerializeTupleVariant = SerializeTupleVariantAsMapValue<S::SerializeMap>;
111
112
    #[cfg(not(any(feature = "std", feature = "alloc")))]
113
    type SerializeStructVariant = Impossible<S::Ok, S::Error>;
114
    #[cfg(any(feature = "std", feature = "alloc"))]
115
    type SerializeStructVariant = SerializeStructVariantAsMapValue<S::SerializeMap>;
116
117
0
    fn serialize_bool(self, _: bool) -> Result<Self::Ok, Self::Error> {
118
0
        Err(self.bad_type(Unsupported::Boolean))
119
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_bool
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_bool
120
121
0
    fn serialize_i8(self, _: i8) -> Result<Self::Ok, Self::Error> {
122
0
        Err(self.bad_type(Unsupported::Integer))
123
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_i8
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_i8
124
125
0
    fn serialize_i16(self, _: i16) -> Result<Self::Ok, Self::Error> {
126
0
        Err(self.bad_type(Unsupported::Integer))
127
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_i16
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_i16
128
129
0
    fn serialize_i32(self, _: i32) -> Result<Self::Ok, Self::Error> {
130
0
        Err(self.bad_type(Unsupported::Integer))
131
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_i32
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_i32
132
133
0
    fn serialize_i64(self, _: i64) -> Result<Self::Ok, Self::Error> {
134
0
        Err(self.bad_type(Unsupported::Integer))
135
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_i64
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_i64
136
137
0
    fn serialize_u8(self, _: u8) -> Result<Self::Ok, Self::Error> {
138
0
        Err(self.bad_type(Unsupported::Integer))
139
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_u8
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_u8
140
141
0
    fn serialize_u16(self, _: u16) -> Result<Self::Ok, Self::Error> {
142
0
        Err(self.bad_type(Unsupported::Integer))
143
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_u16
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_u16
144
145
0
    fn serialize_u32(self, _: u32) -> Result<Self::Ok, Self::Error> {
146
0
        Err(self.bad_type(Unsupported::Integer))
147
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_u32
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_u32
148
149
0
    fn serialize_u64(self, _: u64) -> Result<Self::Ok, Self::Error> {
150
0
        Err(self.bad_type(Unsupported::Integer))
151
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_u64
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_u64
152
153
0
    fn serialize_f32(self, _: f32) -> Result<Self::Ok, Self::Error> {
154
0
        Err(self.bad_type(Unsupported::Float))
155
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_f32
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_f32
156
157
0
    fn serialize_f64(self, _: f64) -> Result<Self::Ok, Self::Error> {
158
0
        Err(self.bad_type(Unsupported::Float))
159
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_f64
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_f64
160
161
0
    fn serialize_char(self, _: char) -> Result<Self::Ok, Self::Error> {
162
0
        Err(self.bad_type(Unsupported::Char))
163
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_char
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_char
164
165
0
    fn serialize_str(self, _: &str) -> Result<Self::Ok, Self::Error> {
166
0
        Err(self.bad_type(Unsupported::String))
167
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_str
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_str
168
169
0
    fn serialize_bytes(self, _: &[u8]) -> Result<Self::Ok, Self::Error> {
170
0
        Err(self.bad_type(Unsupported::ByteArray))
171
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_bytes
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_bytes
172
173
0
    fn serialize_none(self) -> Result<Self::Ok, Self::Error> {
174
0
        Err(self.bad_type(Unsupported::Optional))
175
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_none
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_none
176
177
0
    fn serialize_some<T>(self, _: &T) -> Result<Self::Ok, Self::Error>
178
0
    where
179
0
        T: ?Sized + Serialize,
180
    {
181
0
        Err(self.bad_type(Unsupported::Optional))
182
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_some::<_>
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_some::<_>
183
184
0
    fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
185
0
        let mut map = tri!(self.delegate.serialize_map(Some(1)));
186
0
        tri!(map.serialize_entry(self.tag, self.variant_name));
187
0
        map.end()
188
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_unit
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_unit
189
190
0
    fn serialize_unit_struct(self, _: &'static str) -> Result<Self::Ok, Self::Error> {
191
0
        let mut map = tri!(self.delegate.serialize_map(Some(1)));
192
0
        tri!(map.serialize_entry(self.tag, self.variant_name));
193
0
        map.end()
194
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_unit_struct
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_unit_struct
195
196
0
    fn serialize_unit_variant(
197
0
        self,
198
0
        _: &'static str,
199
0
        _: u32,
200
0
        inner_variant: &'static str,
201
0
    ) -> Result<Self::Ok, Self::Error> {
202
0
        let mut map = tri!(self.delegate.serialize_map(Some(2)));
203
0
        tri!(map.serialize_entry(self.tag, self.variant_name));
204
0
        tri!(map.serialize_entry(inner_variant, &()));
205
0
        map.end()
206
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_unit_variant
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_unit_variant
207
208
0
    fn serialize_newtype_struct<T>(
209
0
        self,
210
0
        _: &'static str,
211
0
        value: &T,
212
0
    ) -> Result<Self::Ok, Self::Error>
213
0
    where
214
0
        T: ?Sized + Serialize,
215
    {
216
0
        value.serialize(self)
217
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_newtype_struct::<_>
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_newtype_struct::<_>
218
219
0
    fn serialize_newtype_variant<T>(
220
0
        self,
221
0
        _: &'static str,
222
0
        _: u32,
223
0
        inner_variant: &'static str,
224
0
        inner_value: &T,
225
0
    ) -> Result<Self::Ok, Self::Error>
226
0
    where
227
0
        T: ?Sized + Serialize,
228
    {
229
0
        let mut map = tri!(self.delegate.serialize_map(Some(2)));
230
0
        tri!(map.serialize_entry(self.tag, self.variant_name));
231
0
        tri!(map.serialize_entry(inner_variant, inner_value));
232
0
        map.end()
233
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_newtype_variant::<_>
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_newtype_variant::<_>
234
235
0
    fn serialize_seq(self, _: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> {
236
0
        Err(self.bad_type(Unsupported::Sequence))
237
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_seq
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_seq
238
239
0
    fn serialize_tuple(self, _: usize) -> Result<Self::SerializeTuple, Self::Error> {
240
0
        Err(self.bad_type(Unsupported::Tuple))
241
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_tuple
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_tuple
242
243
0
    fn serialize_tuple_struct(
244
0
        self,
245
0
        _: &'static str,
246
0
        _: usize,
247
0
    ) -> Result<Self::SerializeTupleStruct, Self::Error> {
248
0
        Err(self.bad_type(Unsupported::TupleStruct))
249
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_tuple_struct
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_tuple_struct
250
251
    #[cfg(not(any(feature = "std", feature = "alloc")))]
252
    fn serialize_tuple_variant(
253
        self,
254
        _: &'static str,
255
        _: u32,
256
        _: &'static str,
257
        _: usize,
258
    ) -> Result<Self::SerializeTupleVariant, Self::Error> {
259
        // Lack of push-based serialization means we need to buffer the content
260
        // of the tuple variant, so it requires std.
261
        Err(self.bad_type(Unsupported::Enum))
262
    }
263
264
    #[cfg(any(feature = "std", feature = "alloc"))]
265
0
    fn serialize_tuple_variant(
266
0
        self,
267
0
        _: &'static str,
268
0
        _: u32,
269
0
        inner_variant: &'static str,
270
0
        len: usize,
271
0
    ) -> Result<Self::SerializeTupleVariant, Self::Error> {
272
0
        let mut map = tri!(self.delegate.serialize_map(Some(2)));
273
0
        tri!(map.serialize_entry(self.tag, self.variant_name));
274
0
        tri!(map.serialize_key(inner_variant));
275
0
        Ok(SerializeTupleVariantAsMapValue::new(
276
0
            map,
277
0
            inner_variant,
278
0
            len,
279
0
        ))
280
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_tuple_variant
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_tuple_variant
281
282
0
    fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap, Self::Error> {
283
0
        let mut map = tri!(self.delegate.serialize_map(len.map(|len| len + 1)));
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_map::{closure#0}
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_map::{closure#0}
284
0
        tri!(map.serialize_entry(self.tag, self.variant_name));
285
0
        Ok(map)
286
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_map
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_map
287
288
0
    fn serialize_struct(
289
0
        self,
290
0
        name: &'static str,
291
0
        len: usize,
292
0
    ) -> Result<Self::SerializeStruct, Self::Error> {
293
0
        let mut state = tri!(self.delegate.serialize_struct(name, len + 1));
294
0
        tri!(state.serialize_field(self.tag, self.variant_name));
295
0
        Ok(state)
296
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_struct
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_struct
297
298
    #[cfg(not(any(feature = "std", feature = "alloc")))]
299
    fn serialize_struct_variant(
300
        self,
301
        _: &'static str,
302
        _: u32,
303
        _: &'static str,
304
        _: usize,
305
    ) -> Result<Self::SerializeStructVariant, Self::Error> {
306
        // Lack of push-based serialization means we need to buffer the content
307
        // of the struct variant, so it requires std.
308
        Err(self.bad_type(Unsupported::Enum))
309
    }
310
311
    #[cfg(any(feature = "std", feature = "alloc"))]
312
0
    fn serialize_struct_variant(
313
0
        self,
314
0
        _: &'static str,
315
0
        _: u32,
316
0
        inner_variant: &'static str,
317
0
        len: usize,
318
0
    ) -> Result<Self::SerializeStructVariant, Self::Error> {
319
0
        let mut map = tri!(self.delegate.serialize_map(Some(2)));
320
0
        tri!(map.serialize_entry(self.tag, self.variant_name));
321
0
        tri!(map.serialize_key(inner_variant));
322
0
        Ok(SerializeStructVariantAsMapValue::new(
323
0
            map,
324
0
            inner_variant,
325
0
            len,
326
0
        ))
327
0
    }
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_struct_variant
Unexecuted instantiation: <serde::__private::ser::TaggedSerializer<_> as serde::ser::Serializer>::serialize_struct_variant
328
329
    #[cfg(not(any(feature = "std", feature = "alloc")))]
330
    fn collect_str<T>(self, _: &T) -> Result<Self::Ok, Self::Error>
331
    where
332
        T: ?Sized + Display,
333
    {
334
        Err(self.bad_type(Unsupported::String))
335
    }
336
}
337
338
#[cfg(any(feature = "std", feature = "alloc"))]
339
mod content {
340
    use crate::lib::*;
341
342
    use crate::ser::{self, Serialize, Serializer};
343
344
    pub struct SerializeTupleVariantAsMapValue<M> {
345
        map: M,
346
        name: &'static str,
347
        fields: Vec<Content>,
348
    }
349
350
    impl<M> SerializeTupleVariantAsMapValue<M> {
351
0
        pub fn new(map: M, name: &'static str, len: usize) -> Self {
352
0
            SerializeTupleVariantAsMapValue {
353
0
                map,
354
0
                name,
355
0
                fields: Vec::with_capacity(len),
356
0
            }
357
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleVariantAsMapValue<_>>::new
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleVariantAsMapValue<_>>::new
358
    }
359
360
    impl<M> ser::SerializeTupleVariant for SerializeTupleVariantAsMapValue<M>
361
    where
362
        M: ser::SerializeMap,
363
    {
364
        type Ok = M::Ok;
365
        type Error = M::Error;
366
367
0
        fn serialize_field<T>(&mut self, value: &T) -> Result<(), M::Error>
368
0
        where
369
0
            T: ?Sized + Serialize,
370
        {
371
0
            let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
372
0
            self.fields.push(value);
373
0
            Ok(())
374
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleVariantAsMapValue<_> as serde::ser::SerializeTupleVariant>::serialize_field::<_>
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleVariantAsMapValue<_> as serde::ser::SerializeTupleVariant>::serialize_field::<_>
375
376
0
        fn end(mut self) -> Result<M::Ok, M::Error> {
377
0
            tri!(self
378
0
                .map
379
0
                .serialize_value(&Content::TupleStruct(self.name, self.fields)));
380
0
            self.map.end()
381
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleVariantAsMapValue<_> as serde::ser::SerializeTupleVariant>::end
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleVariantAsMapValue<_> as serde::ser::SerializeTupleVariant>::end
382
    }
383
384
    pub struct SerializeStructVariantAsMapValue<M> {
385
        map: M,
386
        name: &'static str,
387
        fields: Vec<(&'static str, Content)>,
388
    }
389
390
    impl<M> SerializeStructVariantAsMapValue<M> {
391
0
        pub fn new(map: M, name: &'static str, len: usize) -> Self {
392
0
            SerializeStructVariantAsMapValue {
393
0
                map,
394
0
                name,
395
0
                fields: Vec::with_capacity(len),
396
0
            }
397
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeStructVariantAsMapValue<_>>::new
Unexecuted instantiation: <serde::__private::ser::content::SerializeStructVariantAsMapValue<_>>::new
398
    }
399
400
    impl<M> ser::SerializeStructVariant for SerializeStructVariantAsMapValue<M>
401
    where
402
        M: ser::SerializeMap,
403
    {
404
        type Ok = M::Ok;
405
        type Error = M::Error;
406
407
0
        fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), M::Error>
408
0
        where
409
0
            T: ?Sized + Serialize,
410
        {
411
0
            let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
412
0
            self.fields.push((key, value));
413
0
            Ok(())
414
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeStructVariantAsMapValue<_> as serde::ser::SerializeStructVariant>::serialize_field::<_>
Unexecuted instantiation: <serde::__private::ser::content::SerializeStructVariantAsMapValue<_> as serde::ser::SerializeStructVariant>::serialize_field::<_>
415
416
0
        fn end(mut self) -> Result<M::Ok, M::Error> {
417
0
            tri!(self
418
0
                .map
419
0
                .serialize_value(&Content::Struct(self.name, self.fields)));
420
0
            self.map.end()
421
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeStructVariantAsMapValue<_> as serde::ser::SerializeStructVariant>::end
Unexecuted instantiation: <serde::__private::ser::content::SerializeStructVariantAsMapValue<_> as serde::ser::SerializeStructVariant>::end
422
    }
423
424
    pub enum Content {
425
        Bool(bool),
426
427
        U8(u8),
428
        U16(u16),
429
        U32(u32),
430
        U64(u64),
431
432
        I8(i8),
433
        I16(i16),
434
        I32(i32),
435
        I64(i64),
436
437
        F32(f32),
438
        F64(f64),
439
440
        Char(char),
441
        String(String),
442
        Bytes(Vec<u8>),
443
444
        None,
445
        Some(Box<Content>),
446
447
        Unit,
448
        UnitStruct(&'static str),
449
        UnitVariant(&'static str, u32, &'static str),
450
        NewtypeStruct(&'static str, Box<Content>),
451
        NewtypeVariant(&'static str, u32, &'static str, Box<Content>),
452
453
        Seq(Vec<Content>),
454
        Tuple(Vec<Content>),
455
        TupleStruct(&'static str, Vec<Content>),
456
        TupleVariant(&'static str, u32, &'static str, Vec<Content>),
457
        Map(Vec<(Content, Content)>),
458
        Struct(&'static str, Vec<(&'static str, Content)>),
459
        StructVariant(
460
            &'static str,
461
            u32,
462
            &'static str,
463
            Vec<(&'static str, Content)>,
464
        ),
465
    }
466
467
    impl Serialize for Content {
468
0
        fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
469
0
        where
470
0
            S: Serializer,
471
        {
472
0
            match *self {
473
0
                Content::Bool(b) => serializer.serialize_bool(b),
474
0
                Content::U8(u) => serializer.serialize_u8(u),
475
0
                Content::U16(u) => serializer.serialize_u16(u),
476
0
                Content::U32(u) => serializer.serialize_u32(u),
477
0
                Content::U64(u) => serializer.serialize_u64(u),
478
0
                Content::I8(i) => serializer.serialize_i8(i),
479
0
                Content::I16(i) => serializer.serialize_i16(i),
480
0
                Content::I32(i) => serializer.serialize_i32(i),
481
0
                Content::I64(i) => serializer.serialize_i64(i),
482
0
                Content::F32(f) => serializer.serialize_f32(f),
483
0
                Content::F64(f) => serializer.serialize_f64(f),
484
0
                Content::Char(c) => serializer.serialize_char(c),
485
0
                Content::String(ref s) => serializer.serialize_str(s),
486
0
                Content::Bytes(ref b) => serializer.serialize_bytes(b),
487
0
                Content::None => serializer.serialize_none(),
488
0
                Content::Some(ref c) => serializer.serialize_some(&**c),
489
0
                Content::Unit => serializer.serialize_unit(),
490
0
                Content::UnitStruct(n) => serializer.serialize_unit_struct(n),
491
0
                Content::UnitVariant(n, i, v) => serializer.serialize_unit_variant(n, i, v),
492
0
                Content::NewtypeStruct(n, ref c) => serializer.serialize_newtype_struct(n, &**c),
493
0
                Content::NewtypeVariant(n, i, v, ref c) => {
494
0
                    serializer.serialize_newtype_variant(n, i, v, &**c)
495
                }
496
0
                Content::Seq(ref elements) => elements.serialize(serializer),
497
0
                Content::Tuple(ref elements) => {
498
                    use crate::ser::SerializeTuple;
499
0
                    let mut tuple = tri!(serializer.serialize_tuple(elements.len()));
500
0
                    for e in elements {
501
0
                        tri!(tuple.serialize_element(e));
502
                    }
503
0
                    tuple.end()
504
                }
505
0
                Content::TupleStruct(n, ref fields) => {
506
                    use crate::ser::SerializeTupleStruct;
507
0
                    let mut ts = tri!(serializer.serialize_tuple_struct(n, fields.len()));
508
0
                    for f in fields {
509
0
                        tri!(ts.serialize_field(f));
510
                    }
511
0
                    ts.end()
512
                }
513
0
                Content::TupleVariant(n, i, v, ref fields) => {
514
                    use crate::ser::SerializeTupleVariant;
515
0
                    let mut tv = tri!(serializer.serialize_tuple_variant(n, i, v, fields.len()));
516
0
                    for f in fields {
517
0
                        tri!(tv.serialize_field(f));
518
                    }
519
0
                    tv.end()
520
                }
521
0
                Content::Map(ref entries) => {
522
                    use crate::ser::SerializeMap;
523
0
                    let mut map = tri!(serializer.serialize_map(Some(entries.len())));
524
0
                    for (k, v) in entries {
525
0
                        tri!(map.serialize_entry(k, v));
526
                    }
527
0
                    map.end()
528
                }
529
0
                Content::Struct(n, ref fields) => {
530
                    use crate::ser::SerializeStruct;
531
0
                    let mut s = tri!(serializer.serialize_struct(n, fields.len()));
532
0
                    for &(k, ref v) in fields {
533
0
                        tri!(s.serialize_field(k, v));
534
                    }
535
0
                    s.end()
536
                }
537
0
                Content::StructVariant(n, i, v, ref fields) => {
538
                    use crate::ser::SerializeStructVariant;
539
0
                    let mut sv = tri!(serializer.serialize_struct_variant(n, i, v, fields.len()));
540
0
                    for &(k, ref v) in fields {
541
0
                        tri!(sv.serialize_field(k, v));
542
                    }
543
0
                    sv.end()
544
                }
545
            }
546
0
        }
Unexecuted instantiation: <serde::__private::ser::content::Content as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <serde::__private::ser::content::Content as serde::ser::Serialize>::serialize::<_>
547
    }
548
549
    pub struct ContentSerializer<E> {
550
        error: PhantomData<E>,
551
    }
552
553
    impl<E> ContentSerializer<E> {
554
0
        pub fn new() -> Self {
555
0
            ContentSerializer { error: PhantomData }
556
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_>>::new
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_>>::new
557
    }
558
559
    impl<E> Serializer for ContentSerializer<E>
560
    where
561
        E: ser::Error,
562
    {
563
        type Ok = Content;
564
        type Error = E;
565
566
        type SerializeSeq = SerializeSeq<E>;
567
        type SerializeTuple = SerializeTuple<E>;
568
        type SerializeTupleStruct = SerializeTupleStruct<E>;
569
        type SerializeTupleVariant = SerializeTupleVariant<E>;
570
        type SerializeMap = SerializeMap<E>;
571
        type SerializeStruct = SerializeStruct<E>;
572
        type SerializeStructVariant = SerializeStructVariant<E>;
573
574
0
        fn serialize_bool(self, v: bool) -> Result<Content, E> {
575
0
            Ok(Content::Bool(v))
576
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_bool
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_bool
577
578
0
        fn serialize_i8(self, v: i8) -> Result<Content, E> {
579
0
            Ok(Content::I8(v))
580
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_i8
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_i8
581
582
0
        fn serialize_i16(self, v: i16) -> Result<Content, E> {
583
0
            Ok(Content::I16(v))
584
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_i16
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_i16
585
586
0
        fn serialize_i32(self, v: i32) -> Result<Content, E> {
587
0
            Ok(Content::I32(v))
588
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_i32
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_i32
589
590
0
        fn serialize_i64(self, v: i64) -> Result<Content, E> {
591
0
            Ok(Content::I64(v))
592
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_i64
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_i64
593
594
0
        fn serialize_u8(self, v: u8) -> Result<Content, E> {
595
0
            Ok(Content::U8(v))
596
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_u8
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_u8
597
598
0
        fn serialize_u16(self, v: u16) -> Result<Content, E> {
599
0
            Ok(Content::U16(v))
600
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_u16
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_u16
601
602
0
        fn serialize_u32(self, v: u32) -> Result<Content, E> {
603
0
            Ok(Content::U32(v))
604
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_u32
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_u32
605
606
0
        fn serialize_u64(self, v: u64) -> Result<Content, E> {
607
0
            Ok(Content::U64(v))
608
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_u64
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_u64
609
610
0
        fn serialize_f32(self, v: f32) -> Result<Content, E> {
611
0
            Ok(Content::F32(v))
612
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_f32
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_f32
613
614
0
        fn serialize_f64(self, v: f64) -> Result<Content, E> {
615
0
            Ok(Content::F64(v))
616
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_f64
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_f64
617
618
0
        fn serialize_char(self, v: char) -> Result<Content, E> {
619
0
            Ok(Content::Char(v))
620
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_char
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_char
621
622
0
        fn serialize_str(self, value: &str) -> Result<Content, E> {
623
0
            Ok(Content::String(value.to_owned()))
624
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_str
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_str
625
626
0
        fn serialize_bytes(self, value: &[u8]) -> Result<Content, E> {
627
0
            Ok(Content::Bytes(value.to_owned()))
628
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_bytes
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_bytes
629
630
0
        fn serialize_none(self) -> Result<Content, E> {
631
0
            Ok(Content::None)
632
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_none
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_none
633
634
0
        fn serialize_some<T>(self, value: &T) -> Result<Content, E>
635
0
        where
636
0
            T: ?Sized + Serialize,
637
        {
638
0
            Ok(Content::Some(Box::new(tri!(value.serialize(self)))))
639
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_some::<_>
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_some::<_>
640
641
0
        fn serialize_unit(self) -> Result<Content, E> {
642
0
            Ok(Content::Unit)
643
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_unit
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_unit
644
645
0
        fn serialize_unit_struct(self, name: &'static str) -> Result<Content, E> {
646
0
            Ok(Content::UnitStruct(name))
647
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_unit_struct
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_unit_struct
648
649
0
        fn serialize_unit_variant(
650
0
            self,
651
0
            name: &'static str,
652
0
            variant_index: u32,
653
0
            variant: &'static str,
654
0
        ) -> Result<Content, E> {
655
0
            Ok(Content::UnitVariant(name, variant_index, variant))
656
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_unit_variant
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_unit_variant
657
658
0
        fn serialize_newtype_struct<T>(self, name: &'static str, value: &T) -> Result<Content, E>
659
0
        where
660
0
            T: ?Sized + Serialize,
661
        {
662
            Ok(Content::NewtypeStruct(
663
0
                name,
664
0
                Box::new(tri!(value.serialize(self))),
665
            ))
666
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_newtype_struct::<_>
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_newtype_struct::<_>
667
668
0
        fn serialize_newtype_variant<T>(
669
0
            self,
670
0
            name: &'static str,
671
0
            variant_index: u32,
672
0
            variant: &'static str,
673
0
            value: &T,
674
0
        ) -> Result<Content, E>
675
0
        where
676
0
            T: ?Sized + Serialize,
677
        {
678
            Ok(Content::NewtypeVariant(
679
0
                name,
680
0
                variant_index,
681
0
                variant,
682
0
                Box::new(tri!(value.serialize(self))),
683
            ))
684
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_newtype_variant::<_>
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_newtype_variant::<_>
685
686
0
        fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq, E> {
687
0
            Ok(SerializeSeq {
688
0
                elements: Vec::with_capacity(len.unwrap_or(0)),
689
0
                error: PhantomData,
690
0
            })
691
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_seq
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_seq
692
693
0
        fn serialize_tuple(self, len: usize) -> Result<Self::SerializeTuple, E> {
694
0
            Ok(SerializeTuple {
695
0
                elements: Vec::with_capacity(len),
696
0
                error: PhantomData,
697
0
            })
698
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_tuple
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_tuple
699
700
0
        fn serialize_tuple_struct(
701
0
            self,
702
0
            name: &'static str,
703
0
            len: usize,
704
0
        ) -> Result<Self::SerializeTupleStruct, E> {
705
0
            Ok(SerializeTupleStruct {
706
0
                name,
707
0
                fields: Vec::with_capacity(len),
708
0
                error: PhantomData,
709
0
            })
710
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_tuple_struct
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_tuple_struct
711
712
0
        fn serialize_tuple_variant(
713
0
            self,
714
0
            name: &'static str,
715
0
            variant_index: u32,
716
0
            variant: &'static str,
717
0
            len: usize,
718
0
        ) -> Result<Self::SerializeTupleVariant, E> {
719
0
            Ok(SerializeTupleVariant {
720
0
                name,
721
0
                variant_index,
722
0
                variant,
723
0
                fields: Vec::with_capacity(len),
724
0
                error: PhantomData,
725
0
            })
726
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_tuple_variant
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_tuple_variant
727
728
0
        fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap, E> {
729
0
            Ok(SerializeMap {
730
0
                entries: Vec::with_capacity(len.unwrap_or(0)),
731
0
                key: None,
732
0
                error: PhantomData,
733
0
            })
734
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_map
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_map
735
736
0
        fn serialize_struct(
737
0
            self,
738
0
            name: &'static str,
739
0
            len: usize,
740
0
        ) -> Result<Self::SerializeStruct, E> {
741
0
            Ok(SerializeStruct {
742
0
                name,
743
0
                fields: Vec::with_capacity(len),
744
0
                error: PhantomData,
745
0
            })
746
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_struct
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_struct
747
748
0
        fn serialize_struct_variant(
749
0
            self,
750
0
            name: &'static str,
751
0
            variant_index: u32,
752
0
            variant: &'static str,
753
0
            len: usize,
754
0
        ) -> Result<Self::SerializeStructVariant, E> {
755
0
            Ok(SerializeStructVariant {
756
0
                name,
757
0
                variant_index,
758
0
                variant,
759
0
                fields: Vec::with_capacity(len),
760
0
                error: PhantomData,
761
0
            })
762
0
        }
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_struct_variant
Unexecuted instantiation: <serde::__private::ser::content::ContentSerializer<_> as serde::ser::Serializer>::serialize_struct_variant
763
    }
764
765
    pub struct SerializeSeq<E> {
766
        elements: Vec<Content>,
767
        error: PhantomData<E>,
768
    }
769
770
    impl<E> ser::SerializeSeq for SerializeSeq<E>
771
    where
772
        E: ser::Error,
773
    {
774
        type Ok = Content;
775
        type Error = E;
776
777
0
        fn serialize_element<T>(&mut self, value: &T) -> Result<(), E>
778
0
        where
779
0
            T: ?Sized + Serialize,
780
        {
781
0
            let value = tri!(value.serialize(ContentSerializer::<E>::new()));
782
0
            self.elements.push(value);
783
0
            Ok(())
784
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeSeq<_> as serde::ser::SerializeSeq>::serialize_element::<_>
Unexecuted instantiation: <serde::__private::ser::content::SerializeSeq<_> as serde::ser::SerializeSeq>::serialize_element::<_>
785
786
0
        fn end(self) -> Result<Content, E> {
787
0
            Ok(Content::Seq(self.elements))
788
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeSeq<_> as serde::ser::SerializeSeq>::end
Unexecuted instantiation: <serde::__private::ser::content::SerializeSeq<_> as serde::ser::SerializeSeq>::end
789
    }
790
791
    pub struct SerializeTuple<E> {
792
        elements: Vec<Content>,
793
        error: PhantomData<E>,
794
    }
795
796
    impl<E> ser::SerializeTuple for SerializeTuple<E>
797
    where
798
        E: ser::Error,
799
    {
800
        type Ok = Content;
801
        type Error = E;
802
803
0
        fn serialize_element<T>(&mut self, value: &T) -> Result<(), E>
804
0
        where
805
0
            T: ?Sized + Serialize,
806
        {
807
0
            let value = tri!(value.serialize(ContentSerializer::<E>::new()));
808
0
            self.elements.push(value);
809
0
            Ok(())
810
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeTuple<_> as serde::ser::SerializeTuple>::serialize_element::<_>
Unexecuted instantiation: <serde::__private::ser::content::SerializeTuple<_> as serde::ser::SerializeTuple>::serialize_element::<_>
811
812
0
        fn end(self) -> Result<Content, E> {
813
0
            Ok(Content::Tuple(self.elements))
814
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeTuple<_> as serde::ser::SerializeTuple>::end
Unexecuted instantiation: <serde::__private::ser::content::SerializeTuple<_> as serde::ser::SerializeTuple>::end
815
    }
816
817
    pub struct SerializeTupleStruct<E> {
818
        name: &'static str,
819
        fields: Vec<Content>,
820
        error: PhantomData<E>,
821
    }
822
823
    impl<E> ser::SerializeTupleStruct for SerializeTupleStruct<E>
824
    where
825
        E: ser::Error,
826
    {
827
        type Ok = Content;
828
        type Error = E;
829
830
0
        fn serialize_field<T>(&mut self, value: &T) -> Result<(), E>
831
0
        where
832
0
            T: ?Sized + Serialize,
833
        {
834
0
            let value = tri!(value.serialize(ContentSerializer::<E>::new()));
835
0
            self.fields.push(value);
836
0
            Ok(())
837
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleStruct<_> as serde::ser::SerializeTupleStruct>::serialize_field::<_>
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleStruct<_> as serde::ser::SerializeTupleStruct>::serialize_field::<_>
838
839
0
        fn end(self) -> Result<Content, E> {
840
0
            Ok(Content::TupleStruct(self.name, self.fields))
841
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleStruct<_> as serde::ser::SerializeTupleStruct>::end
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleStruct<_> as serde::ser::SerializeTupleStruct>::end
842
    }
843
844
    pub struct SerializeTupleVariant<E> {
845
        name: &'static str,
846
        variant_index: u32,
847
        variant: &'static str,
848
        fields: Vec<Content>,
849
        error: PhantomData<E>,
850
    }
851
852
    impl<E> ser::SerializeTupleVariant for SerializeTupleVariant<E>
853
    where
854
        E: ser::Error,
855
    {
856
        type Ok = Content;
857
        type Error = E;
858
859
0
        fn serialize_field<T>(&mut self, value: &T) -> Result<(), E>
860
0
        where
861
0
            T: ?Sized + Serialize,
862
        {
863
0
            let value = tri!(value.serialize(ContentSerializer::<E>::new()));
864
0
            self.fields.push(value);
865
0
            Ok(())
866
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleVariant<_> as serde::ser::SerializeTupleVariant>::serialize_field::<_>
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleVariant<_> as serde::ser::SerializeTupleVariant>::serialize_field::<_>
867
868
0
        fn end(self) -> Result<Content, E> {
869
0
            Ok(Content::TupleVariant(
870
0
                self.name,
871
0
                self.variant_index,
872
0
                self.variant,
873
0
                self.fields,
874
0
            ))
875
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleVariant<_> as serde::ser::SerializeTupleVariant>::end
Unexecuted instantiation: <serde::__private::ser::content::SerializeTupleVariant<_> as serde::ser::SerializeTupleVariant>::end
876
    }
877
878
    pub struct SerializeMap<E> {
879
        entries: Vec<(Content, Content)>,
880
        key: Option<Content>,
881
        error: PhantomData<E>,
882
    }
883
884
    impl<E> ser::SerializeMap for SerializeMap<E>
885
    where
886
        E: ser::Error,
887
    {
888
        type Ok = Content;
889
        type Error = E;
890
891
0
        fn serialize_key<T>(&mut self, key: &T) -> Result<(), E>
892
0
        where
893
0
            T: ?Sized + Serialize,
894
        {
895
0
            let key = tri!(key.serialize(ContentSerializer::<E>::new()));
896
0
            self.key = Some(key);
897
0
            Ok(())
898
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeMap<_> as serde::ser::SerializeMap>::serialize_key::<_>
Unexecuted instantiation: <serde::__private::ser::content::SerializeMap<_> as serde::ser::SerializeMap>::serialize_key::<_>
899
900
0
        fn serialize_value<T>(&mut self, value: &T) -> Result<(), E>
901
0
        where
902
0
            T: ?Sized + Serialize,
903
        {
904
0
            let key = self
905
0
                .key
906
0
                .take()
907
0
                .expect("serialize_value called before serialize_key");
908
0
            let value = tri!(value.serialize(ContentSerializer::<E>::new()));
909
0
            self.entries.push((key, value));
910
0
            Ok(())
911
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeMap<_> as serde::ser::SerializeMap>::serialize_value::<_>
Unexecuted instantiation: <serde::__private::ser::content::SerializeMap<_> as serde::ser::SerializeMap>::serialize_value::<_>
912
913
0
        fn end(self) -> Result<Content, E> {
914
0
            Ok(Content::Map(self.entries))
915
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeMap<_> as serde::ser::SerializeMap>::end
Unexecuted instantiation: <serde::__private::ser::content::SerializeMap<_> as serde::ser::SerializeMap>::end
916
917
0
        fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), E>
918
0
        where
919
0
            K: ?Sized + Serialize,
920
0
            V: ?Sized + Serialize,
921
        {
922
0
            let key = tri!(key.serialize(ContentSerializer::<E>::new()));
923
0
            let value = tri!(value.serialize(ContentSerializer::<E>::new()));
924
0
            self.entries.push((key, value));
925
0
            Ok(())
926
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeMap<_> as serde::ser::SerializeMap>::serialize_entry::<_, _>
Unexecuted instantiation: <serde::__private::ser::content::SerializeMap<_> as serde::ser::SerializeMap>::serialize_entry::<_, _>
927
    }
928
929
    pub struct SerializeStruct<E> {
930
        name: &'static str,
931
        fields: Vec<(&'static str, Content)>,
932
        error: PhantomData<E>,
933
    }
934
935
    impl<E> ser::SerializeStruct for SerializeStruct<E>
936
    where
937
        E: ser::Error,
938
    {
939
        type Ok = Content;
940
        type Error = E;
941
942
0
        fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), E>
943
0
        where
944
0
            T: ?Sized + Serialize,
945
        {
946
0
            let value = tri!(value.serialize(ContentSerializer::<E>::new()));
947
0
            self.fields.push((key, value));
948
0
            Ok(())
949
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeStruct<_> as serde::ser::SerializeStruct>::serialize_field::<_>
Unexecuted instantiation: <serde::__private::ser::content::SerializeStruct<_> as serde::ser::SerializeStruct>::serialize_field::<_>
950
951
0
        fn end(self) -> Result<Content, E> {
952
0
            Ok(Content::Struct(self.name, self.fields))
953
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeStruct<_> as serde::ser::SerializeStruct>::end
Unexecuted instantiation: <serde::__private::ser::content::SerializeStruct<_> as serde::ser::SerializeStruct>::end
954
    }
955
956
    pub struct SerializeStructVariant<E> {
957
        name: &'static str,
958
        variant_index: u32,
959
        variant: &'static str,
960
        fields: Vec<(&'static str, Content)>,
961
        error: PhantomData<E>,
962
    }
963
964
    impl<E> ser::SerializeStructVariant for SerializeStructVariant<E>
965
    where
966
        E: ser::Error,
967
    {
968
        type Ok = Content;
969
        type Error = E;
970
971
0
        fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), E>
972
0
        where
973
0
            T: ?Sized + Serialize,
974
        {
975
0
            let value = tri!(value.serialize(ContentSerializer::<E>::new()));
976
0
            self.fields.push((key, value));
977
0
            Ok(())
978
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeStructVariant<_> as serde::ser::SerializeStructVariant>::serialize_field::<_>
Unexecuted instantiation: <serde::__private::ser::content::SerializeStructVariant<_> as serde::ser::SerializeStructVariant>::serialize_field::<_>
979
980
0
        fn end(self) -> Result<Content, E> {
981
0
            Ok(Content::StructVariant(
982
0
                self.name,
983
0
                self.variant_index,
984
0
                self.variant,
985
0
                self.fields,
986
0
            ))
987
0
        }
Unexecuted instantiation: <serde::__private::ser::content::SerializeStructVariant<_> as serde::ser::SerializeStructVariant>::end
Unexecuted instantiation: <serde::__private::ser::content::SerializeStructVariant<_> as serde::ser::SerializeStructVariant>::end
988
    }
989
}
990
991
#[cfg(any(feature = "std", feature = "alloc"))]
992
pub struct FlatMapSerializer<'a, M: 'a>(pub &'a mut M);
993
994
#[cfg(any(feature = "std", feature = "alloc"))]
995
impl<'a, M> FlatMapSerializer<'a, M>
996
where
997
    M: SerializeMap + 'a,
998
{
999
0
    fn bad_type(what: Unsupported) -> M::Error {
1000
0
        ser::Error::custom(format_args!(
1001
0
            "can only flatten structs and maps (got {})",
1002
            what
1003
        ))
1004
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_>>::bad_type
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_>>::bad_type
1005
}
1006
1007
#[cfg(any(feature = "std", feature = "alloc"))]
1008
impl<'a, M> Serializer for FlatMapSerializer<'a, M>
1009
where
1010
    M: SerializeMap + 'a,
1011
{
1012
    type Ok = ();
1013
    type Error = M::Error;
1014
1015
    type SerializeSeq = Impossible<Self::Ok, M::Error>;
1016
    type SerializeTuple = Impossible<Self::Ok, M::Error>;
1017
    type SerializeTupleStruct = Impossible<Self::Ok, M::Error>;
1018
    type SerializeMap = FlatMapSerializeMap<'a, M>;
1019
    type SerializeStruct = FlatMapSerializeStruct<'a, M>;
1020
    type SerializeTupleVariant = FlatMapSerializeTupleVariantAsMapValue<'a, M>;
1021
    type SerializeStructVariant = FlatMapSerializeStructVariantAsMapValue<'a, M>;
1022
1023
0
    fn serialize_bool(self, _: bool) -> Result<Self::Ok, Self::Error> {
1024
0
        Err(Self::bad_type(Unsupported::Boolean))
1025
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_bool
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_bool
1026
1027
0
    fn serialize_i8(self, _: i8) -> Result<Self::Ok, Self::Error> {
1028
0
        Err(Self::bad_type(Unsupported::Integer))
1029
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_i8
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_i8
1030
1031
0
    fn serialize_i16(self, _: i16) -> Result<Self::Ok, Self::Error> {
1032
0
        Err(Self::bad_type(Unsupported::Integer))
1033
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_i16
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_i16
1034
1035
0
    fn serialize_i32(self, _: i32) -> Result<Self::Ok, Self::Error> {
1036
0
        Err(Self::bad_type(Unsupported::Integer))
1037
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_i32
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_i32
1038
1039
0
    fn serialize_i64(self, _: i64) -> Result<Self::Ok, Self::Error> {
1040
0
        Err(Self::bad_type(Unsupported::Integer))
1041
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_i64
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_i64
1042
1043
0
    fn serialize_u8(self, _: u8) -> Result<Self::Ok, Self::Error> {
1044
0
        Err(Self::bad_type(Unsupported::Integer))
1045
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_u8
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_u8
1046
1047
0
    fn serialize_u16(self, _: u16) -> Result<Self::Ok, Self::Error> {
1048
0
        Err(Self::bad_type(Unsupported::Integer))
1049
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_u16
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_u16
1050
1051
0
    fn serialize_u32(self, _: u32) -> Result<Self::Ok, Self::Error> {
1052
0
        Err(Self::bad_type(Unsupported::Integer))
1053
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_u32
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_u32
1054
1055
0
    fn serialize_u64(self, _: u64) -> Result<Self::Ok, Self::Error> {
1056
0
        Err(Self::bad_type(Unsupported::Integer))
1057
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_u64
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_u64
1058
1059
0
    fn serialize_f32(self, _: f32) -> Result<Self::Ok, Self::Error> {
1060
0
        Err(Self::bad_type(Unsupported::Float))
1061
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_f32
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_f32
1062
1063
0
    fn serialize_f64(self, _: f64) -> Result<Self::Ok, Self::Error> {
1064
0
        Err(Self::bad_type(Unsupported::Float))
1065
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_f64
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_f64
1066
1067
0
    fn serialize_char(self, _: char) -> Result<Self::Ok, Self::Error> {
1068
0
        Err(Self::bad_type(Unsupported::Char))
1069
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_char
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_char
1070
1071
0
    fn serialize_str(self, _: &str) -> Result<Self::Ok, Self::Error> {
1072
0
        Err(Self::bad_type(Unsupported::String))
1073
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_str
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_str
1074
1075
0
    fn serialize_bytes(self, _: &[u8]) -> Result<Self::Ok, Self::Error> {
1076
0
        Err(Self::bad_type(Unsupported::ByteArray))
1077
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_bytes
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_bytes
1078
1079
0
    fn serialize_none(self) -> Result<Self::Ok, Self::Error> {
1080
0
        Ok(())
1081
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_none
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_none
1082
1083
0
    fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
1084
0
    where
1085
0
        T: ?Sized + Serialize,
1086
    {
1087
0
        value.serialize(self)
1088
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_some::<_>
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_some::<_>
1089
1090
0
    fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
1091
0
        Ok(())
1092
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_unit
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_unit
1093
1094
0
    fn serialize_unit_struct(self, _: &'static str) -> Result<Self::Ok, Self::Error> {
1095
0
        Err(Self::bad_type(Unsupported::UnitStruct))
1096
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_unit_struct
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_unit_struct
1097
1098
0
    fn serialize_unit_variant(
1099
0
        self,
1100
0
        _: &'static str,
1101
0
        _: u32,
1102
0
        _: &'static str,
1103
0
    ) -> Result<Self::Ok, Self::Error> {
1104
0
        Err(Self::bad_type(Unsupported::Enum))
1105
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_unit_variant
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_unit_variant
1106
1107
0
    fn serialize_newtype_struct<T>(
1108
0
        self,
1109
0
        _: &'static str,
1110
0
        value: &T,
1111
0
    ) -> Result<Self::Ok, Self::Error>
1112
0
    where
1113
0
        T: ?Sized + Serialize,
1114
    {
1115
0
        value.serialize(self)
1116
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_newtype_struct::<_>
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_newtype_struct::<_>
1117
1118
0
    fn serialize_newtype_variant<T>(
1119
0
        self,
1120
0
        _: &'static str,
1121
0
        _: u32,
1122
0
        variant: &'static str,
1123
0
        value: &T,
1124
0
    ) -> Result<Self::Ok, Self::Error>
1125
0
    where
1126
0
        T: ?Sized + Serialize,
1127
    {
1128
0
        tri!(self.0.serialize_key(variant));
1129
0
        self.0.serialize_value(value)
1130
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_newtype_variant::<_>
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_newtype_variant::<_>
1131
1132
0
    fn serialize_seq(self, _: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> {
1133
0
        Err(Self::bad_type(Unsupported::Sequence))
1134
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_seq
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_seq
1135
1136
0
    fn serialize_tuple(self, _: usize) -> Result<Self::SerializeTuple, Self::Error> {
1137
0
        Err(Self::bad_type(Unsupported::Tuple))
1138
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_tuple
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_tuple
1139
1140
0
    fn serialize_tuple_struct(
1141
0
        self,
1142
0
        _: &'static str,
1143
0
        _: usize,
1144
0
    ) -> Result<Self::SerializeTupleStruct, Self::Error> {
1145
0
        Err(Self::bad_type(Unsupported::TupleStruct))
1146
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_tuple_struct
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_tuple_struct
1147
1148
0
    fn serialize_tuple_variant(
1149
0
        self,
1150
0
        _: &'static str,
1151
0
        _: u32,
1152
0
        variant: &'static str,
1153
0
        _: usize,
1154
0
    ) -> Result<Self::SerializeTupleVariant, Self::Error> {
1155
0
        tri!(self.0.serialize_key(variant));
1156
0
        Ok(FlatMapSerializeTupleVariantAsMapValue::new(self.0))
1157
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_tuple_variant
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_tuple_variant
1158
1159
0
    fn serialize_map(self, _: Option<usize>) -> Result<Self::SerializeMap, Self::Error> {
1160
0
        Ok(FlatMapSerializeMap(self.0))
1161
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_map
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_map
1162
1163
0
    fn serialize_struct(
1164
0
        self,
1165
0
        _: &'static str,
1166
0
        _: usize,
1167
0
    ) -> Result<Self::SerializeStruct, Self::Error> {
1168
0
        Ok(FlatMapSerializeStruct(self.0))
1169
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_struct
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_struct
1170
1171
0
    fn serialize_struct_variant(
1172
0
        self,
1173
0
        _: &'static str,
1174
0
        _: u32,
1175
0
        inner_variant: &'static str,
1176
0
        _: usize,
1177
0
    ) -> Result<Self::SerializeStructVariant, Self::Error> {
1178
0
        tri!(self.0.serialize_key(inner_variant));
1179
0
        Ok(FlatMapSerializeStructVariantAsMapValue::new(
1180
0
            self.0,
1181
0
            inner_variant,
1182
0
        ))
1183
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_struct_variant
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializer<_> as serde::ser::Serializer>::serialize_struct_variant
1184
}
1185
1186
#[cfg(any(feature = "std", feature = "alloc"))]
1187
pub struct FlatMapSerializeMap<'a, M: 'a>(&'a mut M);
1188
1189
#[cfg(any(feature = "std", feature = "alloc"))]
1190
impl<'a, M> ser::SerializeMap for FlatMapSerializeMap<'a, M>
1191
where
1192
    M: SerializeMap + 'a,
1193
{
1194
    type Ok = ();
1195
    type Error = M::Error;
1196
1197
0
    fn serialize_key<T>(&mut self, key: &T) -> Result<(), Self::Error>
1198
0
    where
1199
0
        T: ?Sized + Serialize,
1200
    {
1201
0
        self.0.serialize_key(key)
1202
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeMap<_> as serde::ser::SerializeMap>::serialize_key::<_>
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeMap<_> as serde::ser::SerializeMap>::serialize_key::<_>
1203
1204
0
    fn serialize_value<T>(&mut self, value: &T) -> Result<(), Self::Error>
1205
0
    where
1206
0
        T: ?Sized + Serialize,
1207
    {
1208
0
        self.0.serialize_value(value)
1209
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeMap<_> as serde::ser::SerializeMap>::serialize_value::<_>
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeMap<_> as serde::ser::SerializeMap>::serialize_value::<_>
1210
1211
0
    fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), Self::Error>
1212
0
    where
1213
0
        K: ?Sized + Serialize,
1214
0
        V: ?Sized + Serialize,
1215
    {
1216
0
        self.0.serialize_entry(key, value)
1217
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeMap<_> as serde::ser::SerializeMap>::serialize_entry::<_, _>
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeMap<_> as serde::ser::SerializeMap>::serialize_entry::<_, _>
1218
1219
0
    fn end(self) -> Result<(), Self::Error> {
1220
0
        Ok(())
1221
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeMap<_> as serde::ser::SerializeMap>::end
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeMap<_> as serde::ser::SerializeMap>::end
1222
}
1223
1224
#[cfg(any(feature = "std", feature = "alloc"))]
1225
pub struct FlatMapSerializeStruct<'a, M: 'a>(&'a mut M);
1226
1227
#[cfg(any(feature = "std", feature = "alloc"))]
1228
impl<'a, M> ser::SerializeStruct for FlatMapSerializeStruct<'a, M>
1229
where
1230
    M: SerializeMap + 'a,
1231
{
1232
    type Ok = ();
1233
    type Error = M::Error;
1234
1235
0
    fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error>
1236
0
    where
1237
0
        T: ?Sized + Serialize,
1238
    {
1239
0
        self.0.serialize_entry(key, value)
1240
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeStruct<_> as serde::ser::SerializeStruct>::serialize_field::<_>
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeStruct<_> as serde::ser::SerializeStruct>::serialize_field::<_>
1241
1242
0
    fn end(self) -> Result<(), Self::Error> {
1243
0
        Ok(())
1244
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeStruct<_> as serde::ser::SerializeStruct>::end
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeStruct<_> as serde::ser::SerializeStruct>::end
1245
}
1246
1247
////////////////////////////////////////////////////////////////////////////////////////////////////
1248
1249
#[cfg(any(feature = "std", feature = "alloc"))]
1250
pub struct FlatMapSerializeTupleVariantAsMapValue<'a, M: 'a> {
1251
    map: &'a mut M,
1252
    fields: Vec<Content>,
1253
}
1254
1255
#[cfg(any(feature = "std", feature = "alloc"))]
1256
impl<'a, M> FlatMapSerializeTupleVariantAsMapValue<'a, M>
1257
where
1258
    M: SerializeMap + 'a,
1259
{
1260
0
    fn new(map: &'a mut M) -> Self {
1261
0
        FlatMapSerializeTupleVariantAsMapValue {
1262
0
            map,
1263
0
            fields: Vec::new(),
1264
0
        }
1265
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeTupleVariantAsMapValue<_>>::new
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeTupleVariantAsMapValue<_>>::new
1266
}
1267
1268
#[cfg(any(feature = "std", feature = "alloc"))]
1269
impl<'a, M> ser::SerializeTupleVariant for FlatMapSerializeTupleVariantAsMapValue<'a, M>
1270
where
1271
    M: SerializeMap + 'a,
1272
{
1273
    type Ok = ();
1274
    type Error = M::Error;
1275
1276
0
    fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
1277
0
    where
1278
0
        T: ?Sized + Serialize,
1279
    {
1280
0
        let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
1281
0
        self.fields.push(value);
1282
0
        Ok(())
1283
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeTupleVariantAsMapValue<_> as serde::ser::SerializeTupleVariant>::serialize_field::<_>
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeTupleVariantAsMapValue<_> as serde::ser::SerializeTupleVariant>::serialize_field::<_>
1284
1285
0
    fn end(self) -> Result<(), Self::Error> {
1286
0
        tri!(self.map.serialize_value(&Content::Seq(self.fields)));
1287
0
        Ok(())
1288
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeTupleVariantAsMapValue<_> as serde::ser::SerializeTupleVariant>::end
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeTupleVariantAsMapValue<_> as serde::ser::SerializeTupleVariant>::end
1289
}
1290
1291
////////////////////////////////////////////////////////////////////////////////////////////////////
1292
1293
#[cfg(any(feature = "std", feature = "alloc"))]
1294
pub struct FlatMapSerializeStructVariantAsMapValue<'a, M: 'a> {
1295
    map: &'a mut M,
1296
    name: &'static str,
1297
    fields: Vec<(&'static str, Content)>,
1298
}
1299
1300
#[cfg(any(feature = "std", feature = "alloc"))]
1301
impl<'a, M> FlatMapSerializeStructVariantAsMapValue<'a, M>
1302
where
1303
    M: SerializeMap + 'a,
1304
{
1305
0
    fn new(map: &'a mut M, name: &'static str) -> FlatMapSerializeStructVariantAsMapValue<'a, M> {
1306
0
        FlatMapSerializeStructVariantAsMapValue {
1307
0
            map,
1308
0
            name,
1309
0
            fields: Vec::new(),
1310
0
        }
1311
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeStructVariantAsMapValue<_>>::new
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeStructVariantAsMapValue<_>>::new
1312
}
1313
1314
#[cfg(any(feature = "std", feature = "alloc"))]
1315
impl<'a, M> ser::SerializeStructVariant for FlatMapSerializeStructVariantAsMapValue<'a, M>
1316
where
1317
    M: SerializeMap + 'a,
1318
{
1319
    type Ok = ();
1320
    type Error = M::Error;
1321
1322
0
    fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error>
1323
0
    where
1324
0
        T: ?Sized + Serialize,
1325
    {
1326
0
        let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
1327
0
        self.fields.push((key, value));
1328
0
        Ok(())
1329
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeStructVariantAsMapValue<_> as serde::ser::SerializeStructVariant>::serialize_field::<_>
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeStructVariantAsMapValue<_> as serde::ser::SerializeStructVariant>::serialize_field::<_>
1330
1331
0
    fn end(self) -> Result<(), Self::Error> {
1332
0
        tri!(self
1333
0
            .map
1334
0
            .serialize_value(&Content::Struct(self.name, self.fields)));
1335
0
        Ok(())
1336
0
    }
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeStructVariantAsMapValue<_> as serde::ser::SerializeStructVariant>::end
Unexecuted instantiation: <serde::__private::ser::FlatMapSerializeStructVariantAsMapValue<_> as serde::ser::SerializeStructVariant>::end
1337
}
1338
1339
pub struct AdjacentlyTaggedEnumVariant {
1340
    pub enum_name: &'static str,
1341
    pub variant_index: u32,
1342
    pub variant_name: &'static str,
1343
}
1344
1345
impl Serialize for AdjacentlyTaggedEnumVariant {
1346
0
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1347
0
    where
1348
0
        S: Serializer,
1349
    {
1350
0
        serializer.serialize_unit_variant(self.enum_name, self.variant_index, self.variant_name)
1351
0
    }
Unexecuted instantiation: <serde::__private::ser::AdjacentlyTaggedEnumVariant as serde::ser::Serialize>::serialize::<_>
Unexecuted instantiation: <serde::__private::ser::AdjacentlyTaggedEnumVariant as serde::ser::Serialize>::serialize::<_>
1352
}
1353
1354
// Error when Serialize for a non_exhaustive remote enum encounters a variant
1355
// that is not recognized.
1356
pub struct CannotSerializeVariant<T>(pub T);
1357
1358
impl<T> Display for CannotSerializeVariant<T>
1359
where
1360
    T: Debug,
1361
{
1362
0
    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1363
0
        write!(formatter, "enum variant cannot be serialized: {:?}", self.0)
1364
0
    }
Unexecuted instantiation: <serde::__private::ser::CannotSerializeVariant<_> as core::fmt::Display>::fmt
Unexecuted instantiation: <serde::__private::ser::CannotSerializeVariant<_> as core::fmt::Display>::fmt
1365
}