1
use serde::de::{self, Visitor};
2

            
3
use super::{Error, Result};
4

            
5
pub struct Deserializer<'a, 'b: 'a> {
6
    de: &'a mut super::Deserializer<'b>,
7
}
8

            
9
impl<'a, 'b: 'a> Deserializer<'a, 'b> {
10
14659
    pub fn new(de: &'a mut super::Deserializer<'b>) -> Self {
11
14659
        Deserializer { de }
12
14659
    }
13
}
14

            
15
impl<'a, 'b: 'a, 'c> de::Deserializer<'b> for &'c mut Deserializer<'a, 'b> {
16
    type Error = Error;
17

            
18
114
    fn deserialize_str<V>(self, visitor: V) -> Result<V::Value>
19
114
    where
20
114
        V: Visitor<'b>,
21
114
    {
22
114
        self.de.deserialize_str(visitor)
23
114
    }
24

            
25
8
    fn deserialize_string<V>(self, visitor: V) -> std::result::Result<V::Value, Self::Error>
26
8
    where
27
8
        V: Visitor<'b>,
28
8
    {
29
8
        self.deserialize_str(visitor)
30
8
    }
31

            
32
98
    fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value>
33
98
    where
34
98
        V: Visitor<'b>,
35
98
    {
36
98
        self.deserialize_str(visitor)
37
98
    }
38

            
39
8
    fn deserialize_any<V>(self, visitor: V) -> Result<V::Value>
40
8
    where
41
8
        V: Visitor<'b>,
42
8
    {
43
8
        self.deserialize_str(visitor)
44
8
    }
45

            
46
4
    fn deserialize_bool<V>(self, _visitor: V) -> Result<V::Value>
47
4
    where
48
4
        V: Visitor<'b>,
49
4
    {
50
4
        Err(Error::ExpectedString)
51
4
    }
52

            
53
4
    fn deserialize_i8<V>(self, _visitor: V) -> Result<V::Value>
54
4
    where
55
4
        V: Visitor<'b>,
56
4
    {
57
4
        Err(Error::ExpectedString)
58
4
    }
59

            
60
4
    fn deserialize_i16<V>(self, _visitor: V) -> Result<V::Value>
61
4
    where
62
4
        V: Visitor<'b>,
63
4
    {
64
4
        Err(Error::ExpectedString)
65
4
    }
66

            
67
4
    fn deserialize_i32<V>(self, _visitor: V) -> Result<V::Value>
68
4
    where
69
4
        V: Visitor<'b>,
70
4
    {
71
4
        Err(Error::ExpectedString)
72
4
    }
73

            
74
4
    fn deserialize_i64<V>(self, _visitor: V) -> Result<V::Value>
75
4
    where
76
4
        V: Visitor<'b>,
77
4
    {
78
4
        Err(Error::ExpectedString)
79
4
    }
80

            
81
    #[cfg(feature = "integer128")]
82
2
    fn deserialize_i128<V>(self, _visitor: V) -> Result<V::Value>
83
2
    where
84
2
        V: Visitor<'b>,
85
2
    {
86
2
        Err(Error::ExpectedString)
87
2
    }
88

            
89
4
    fn deserialize_u8<V>(self, _visitor: V) -> Result<V::Value>
90
4
    where
91
4
        V: Visitor<'b>,
92
4
    {
93
4
        Err(Error::ExpectedString)
94
4
    }
95

            
96
4
    fn deserialize_u16<V>(self, _visitor: V) -> Result<V::Value>
97
4
    where
98
4
        V: Visitor<'b>,
99
4
    {
100
4
        Err(Error::ExpectedString)
101
4
    }
102

            
103
4
    fn deserialize_u32<V>(self, _visitor: V) -> Result<V::Value>
104
4
    where
105
4
        V: Visitor<'b>,
106
4
    {
107
4
        Err(Error::ExpectedString)
108
4
    }
109

            
110
4
    fn deserialize_u64<V>(self, _visitor: V) -> Result<V::Value>
111
4
    where
112
4
        V: Visitor<'b>,
113
4
    {
114
4
        Err(Error::ExpectedString)
115
4
    }
116

            
117
    #[cfg(feature = "integer128")]
118
2
    fn deserialize_u128<V>(self, _visitor: V) -> Result<V::Value>
119
2
    where
120
2
        V: Visitor<'b>,
121
2
    {
122
2
        Err(Error::ExpectedString)
123
2
    }
124

            
125
4
    fn deserialize_f32<V>(self, _visitor: V) -> Result<V::Value>
126
4
    where
127
4
        V: Visitor<'b>,
128
4
    {
129
4
        Err(Error::ExpectedString)
130
4
    }
131

            
132
4
    fn deserialize_f64<V>(self, _visitor: V) -> Result<V::Value>
133
4
    where
134
4
        V: Visitor<'b>,
135
4
    {
136
4
        Err(Error::ExpectedString)
137
4
    }
138

            
139
4
    fn deserialize_char<V>(self, _visitor: V) -> Result<V::Value>
140
4
    where
141
4
        V: Visitor<'b>,
142
4
    {
143
4
        Err(Error::ExpectedString)
144
4
    }
145

            
146
4
    fn deserialize_bytes<V>(self, _visitor: V) -> Result<V::Value>
147
4
    where
148
4
        V: Visitor<'b>,
149
4
    {
150
4
        Err(Error::ExpectedString)
151
4
    }
152

            
153
4
    fn deserialize_byte_buf<V>(self, _visitor: V) -> Result<V::Value>
154
4
    where
155
4
        V: Visitor<'b>,
156
4
    {
157
4
        Err(Error::ExpectedString)
158
4
    }
159

            
160
4
    fn deserialize_option<V>(self, _visitor: V) -> Result<V::Value>
161
4
    where
162
4
        V: Visitor<'b>,
163
4
    {
164
4
        Err(Error::ExpectedString)
165
4
    }
166

            
167
4
    fn deserialize_unit<V>(self, _visitor: V) -> Result<V::Value>
168
4
    where
169
4
        V: Visitor<'b>,
170
4
    {
171
4
        Err(Error::ExpectedString)
172
4
    }
173

            
174
4
    fn deserialize_unit_struct<V>(self, _name: &'static str, _visitor: V) -> Result<V::Value>
175
4
    where
176
4
        V: Visitor<'b>,
177
4
    {
178
4
        Err(Error::ExpectedString)
179
4
    }
180

            
181
4
    fn deserialize_newtype_struct<V>(self, _name: &'static str, _visitor: V) -> Result<V::Value>
182
4
    where
183
4
        V: Visitor<'b>,
184
4
    {
185
4
        Err(Error::ExpectedString)
186
4
    }
187

            
188
4
    fn deserialize_seq<V>(self, _visitor: V) -> Result<V::Value>
189
4
    where
190
4
        V: Visitor<'b>,
191
4
    {
192
4
        Err(Error::ExpectedString)
193
4
    }
194

            
195
4
    fn deserialize_tuple<V>(self, _len: usize, _visitor: V) -> Result<V::Value>
196
4
    where
197
4
        V: Visitor<'b>,
198
4
    {
199
4
        Err(Error::ExpectedString)
200
4
    }
201

            
202
4
    fn deserialize_tuple_struct<V>(
203
4
        self,
204
4
        _name: &'static str,
205
4
        _len: usize,
206
4
        _visitor: V,
207
4
    ) -> Result<V::Value>
208
4
    where
209
4
        V: Visitor<'b>,
210
4
    {
211
4
        Err(Error::ExpectedString)
212
4
    }
213

            
214
4
    fn deserialize_map<V>(self, _visitor: V) -> Result<V::Value>
215
4
    where
216
4
        V: Visitor<'b>,
217
4
    {
218
4
        Err(Error::ExpectedString)
219
4
    }
220

            
221
4
    fn deserialize_struct<V>(
222
4
        self,
223
4
        _name: &'static str,
224
4
        _fields: &'static [&'static str],
225
4
        _visitor: V,
226
4
    ) -> Result<V::Value>
227
4
    where
228
4
        V: Visitor<'b>,
229
4
    {
230
4
        Err(Error::ExpectedString)
231
4
    }
232

            
233
4
    fn deserialize_enum<V>(
234
4
        self,
235
4
        _name: &'static str,
236
4
        _variants: &'static [&'static str],
237
4
        _visitor: V,
238
4
    ) -> Result<V::Value>
239
4
    where
240
4
        V: Visitor<'b>,
241
4
    {
242
4
        Err(Error::ExpectedString)
243
4
    }
244

            
245
4
    fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value>
246
4
    where
247
4
        V: Visitor<'b>,
248
4
    {
249
4
        self.deserialize_any(visitor)
250
4
    }
251
}