diff options
Diffstat (limited to 'src/structs/de.rs')
| -rw-r--r-- | src/structs/de.rs | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/structs/de.rs b/src/structs/de.rs index edd8011..8b2130e 100644 --- a/src/structs/de.rs +++ b/src/structs/de.rs | |||
| @@ -1,5 +1,4 @@ | |||
| 1 | use crate::structs::{Settings, StructError, StructResult}; | 1 | use crate::structs::{Settings, StructError, StructResult}; |
| 2 | use crate::ArchiveError; | ||
| 3 | use serde::de; | 2 | use serde::de; |
| 4 | 3 | ||
| 5 | pub struct ArchiveDeserializer<'de> { | 4 | pub struct ArchiveDeserializer<'de> { |
| @@ -60,14 +59,14 @@ impl<'a, 'de> EnumDeserializer<'a, 'de> { | |||
| 60 | } | 59 | } |
| 61 | 60 | ||
| 62 | impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | 61 | impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { |
| 63 | type Error = ArchiveError<StructError>; | 62 | type Error = StructError; |
| 64 | 63 | ||
| 65 | #[inline] | 64 | #[inline] |
| 66 | fn deserialize_any<V>(self, _visitor: V) -> StructResult<V::Value> | 65 | fn deserialize_any<V>(self, _visitor: V) -> StructResult<V::Value> |
| 67 | where | 66 | where |
| 68 | V: de::Visitor<'de>, | 67 | V: de::Visitor<'de>, |
| 69 | { | 68 | { |
| 70 | Err(StructError::DeserializationNotSupported { type_name: "any" }.into()) | 69 | Err(StructError::DeserializationNotSupported("any")) |
| 71 | } | 70 | } |
| 72 | 71 | ||
| 73 | fn deserialize_bool<V>(self, visitor: V) -> StructResult<V::Value> | 72 | fn deserialize_bool<V>(self, visitor: V) -> StructResult<V::Value> |
| @@ -160,7 +159,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 160 | where | 159 | where |
| 161 | V: de::Visitor<'de>, | 160 | V: de::Visitor<'de>, |
| 162 | { | 161 | { |
| 163 | Err(StructError::DeserializationNotSupported { type_name: "char" }.into()) | 162 | Err(StructError::DeserializationNotSupported("char")) |
| 164 | } | 163 | } |
| 165 | 164 | ||
| 166 | #[inline] | 165 | #[inline] |
| @@ -168,7 +167,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 168 | where | 167 | where |
| 169 | V: de::Visitor<'de>, | 168 | V: de::Visitor<'de>, |
| 170 | { | 169 | { |
| 171 | Err(StructError::DeserializationNotSupported { type_name: "str" }.into()) | 170 | Err(StructError::DeserializationNotSupported("str")) |
| 172 | } | 171 | } |
| 173 | 172 | ||
| 174 | #[inline] | 173 | #[inline] |
| @@ -176,10 +175,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 176 | where | 175 | where |
| 177 | V: de::Visitor<'de>, | 176 | V: de::Visitor<'de>, |
| 178 | { | 177 | { |
| 179 | Err(StructError::DeserializationNotSupported { | 178 | Err(StructError::DeserializationNotSupported("string")) |
| 180 | type_name: "string", | ||
| 181 | } | ||
| 182 | .into()) | ||
| 183 | } | 179 | } |
| 184 | 180 | ||
| 185 | #[inline] | 181 | #[inline] |
| @@ -187,7 +183,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 187 | where | 183 | where |
| 188 | V: de::Visitor<'de>, | 184 | V: de::Visitor<'de>, |
| 189 | { | 185 | { |
| 190 | Err(StructError::DeserializationNotSupported { type_name: "bytes" }.into()) | 186 | Err(StructError::DeserializationNotSupported("bytes")) |
| 191 | } | 187 | } |
| 192 | 188 | ||
| 193 | #[inline] | 189 | #[inline] |
| @@ -195,7 +191,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 195 | where | 191 | where |
| 196 | V: de::Visitor<'de>, | 192 | V: de::Visitor<'de>, |
| 197 | { | 193 | { |
| 198 | Err(StructError::DeserializationNotSupported { type_name: "bytes" }.into()) | 194 | Err(StructError::DeserializationNotSupported("bytes")) |
| 199 | } | 195 | } |
| 200 | 196 | ||
| 201 | #[inline] | 197 | #[inline] |
| @@ -203,10 +199,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 203 | where | 199 | where |
| 204 | V: de::Visitor<'de>, | 200 | V: de::Visitor<'de>, |
| 205 | { | 201 | { |
| 206 | Err(StructError::DeserializationNotSupported { | 202 | Err(StructError::DeserializationNotSupported("optional")) |
| 207 | type_name: "optional", | ||
| 208 | } | ||
| 209 | .into()) | ||
| 210 | } | 203 | } |
| 211 | 204 | ||
| 212 | #[inline] | 205 | #[inline] |
| @@ -242,7 +235,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 242 | where | 235 | where |
| 243 | V: de::Visitor<'de>, | 236 | V: de::Visitor<'de>, |
| 244 | { | 237 | { |
| 245 | Err(StructError::DeserializationNotSupported { type_name: "seq" }.into()) | 238 | Err(StructError::DeserializationNotSupported("seq")) |
| 246 | } | 239 | } |
| 247 | 240 | ||
| 248 | #[inline] | 241 | #[inline] |
| @@ -271,7 +264,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 271 | where | 264 | where |
| 272 | V: de::Visitor<'de>, | 265 | V: de::Visitor<'de>, |
| 273 | { | 266 | { |
| 274 | Err(StructError::DeserializationNotSupported { type_name: "map" }.into()) | 267 | Err(StructError::DeserializationNotSupported("map")) |
| 275 | } | 268 | } |
| 276 | 269 | ||
| 277 | #[inline] | 270 | #[inline] |
| @@ -322,7 +315,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 322 | } | 315 | } |
| 323 | 316 | ||
| 324 | impl<'a, 'de> de::SeqAccess<'de> for SeqDeserializer<'a, 'de> { | 317 | impl<'a, 'de> de::SeqAccess<'de> for SeqDeserializer<'a, 'de> { |
| 325 | type Error = ArchiveError<StructError>; | 318 | type Error = StructError; |
| 326 | 319 | ||
| 327 | fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error> | 320 | fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error> |
| 328 | where | 321 | where |
| @@ -336,7 +329,7 @@ impl<'a, 'de> de::SeqAccess<'de> for SeqDeserializer<'a, 'de> { | |||
| 336 | } | 329 | } |
| 337 | 330 | ||
| 338 | impl<'a, 'de> de::EnumAccess<'de> for EnumDeserializer<'a, 'de> { | 331 | impl<'a, 'de> de::EnumAccess<'de> for EnumDeserializer<'a, 'de> { |
| 339 | type Error = ArchiveError<StructError>; | 332 | type Error = StructError; |
| 340 | type Variant = Self; | 333 | type Variant = Self; |
| 341 | 334 | ||
| 342 | fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant), Self::Error> | 335 | fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant), Self::Error> |
| @@ -348,7 +341,7 @@ impl<'a, 'de> de::EnumAccess<'de> for EnumDeserializer<'a, 'de> { | |||
| 348 | } | 341 | } |
| 349 | 342 | ||
| 350 | impl<'a, 'de> de::VariantAccess<'de> for EnumDeserializer<'a, 'de> { | 343 | impl<'a, 'de> de::VariantAccess<'de> for EnumDeserializer<'a, 'de> { |
| 351 | type Error = ArchiveError<StructError>; | 344 | type Error = StructError; |
| 352 | 345 | ||
| 353 | #[inline] | 346 | #[inline] |
| 354 | fn unit_variant(self) -> Result<(), Self::Error> { | 347 | fn unit_variant(self) -> Result<(), Self::Error> { |
