Skip to content

Commit e0d9c72

Browse files
committed
fmt
1 parent 2594dc7 commit e0d9c72

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

crates/amf0/src/value.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ impl serde::ser::Serialize for Amf0Value<'_> {
285285
impl<'de, 'a: 'de> serde::Deserializer<'de> for &'a Amf0Value<'de> {
286286
type Error = Amf0Error;
287287

288+
serde::forward_to_deserialize_any! {
289+
// need to handle these number types from i8 thru f64; try to deserialze them as their original type then forward as f64
290+
bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string unit
291+
option seq bytes byte_buf map unit_struct newtype_struct tuple tuple_struct
292+
struct enum identifier ignored_any
293+
}
294+
288295
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
289296
where
290297
V: serde::de::Visitor<'de>,
@@ -322,16 +329,12 @@ impl<'de, 'a: 'de> serde::Deserializer<'de> for &'a Amf0Value<'de> {
322329
}
323330
Amf0Value::String(s) => visitor.visit_borrowed_str(s.as_str()),
324331
Amf0Value::Array(a) => visitor.visit_seq(Amf0SeqAccess { iter: a.iter() }),
325-
Amf0Value::Object(o) => visitor.visit_map(Amf0MapAccess { iter: o.iter(), value: None }),
332+
Amf0Value::Object(o) => visitor.visit_map(Amf0MapAccess {
333+
iter: o.iter(),
334+
value: None,
335+
}),
326336
}
327337
}
328-
329-
serde::forward_to_deserialize_any! {
330-
// need to handle these number types from i8 thru f64; try to deserialze them as their original type then forward as f64
331-
bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string unit
332-
option seq bytes byte_buf map unit_struct newtype_struct tuple tuple_struct
333-
struct enum identifier ignored_any
334-
}
335338
}
336339

337340
struct Amf0SeqAccess<'a, 'de> {
@@ -367,7 +370,8 @@ impl<'de, 'a: 'de> serde::de::MapAccess<'de> for Amf0MapAccess<'a, 'de> {
367370
match self.iter.next() {
368371
Some((key, value)) => {
369372
self.value = Some(value);
370-
seed.deserialize(serde::de::IntoDeserializer::into_deserializer(key.as_str())).map(Some)
373+
seed.deserialize(serde::de::IntoDeserializer::into_deserializer(key.as_str()))
374+
.map(Some)
371375
}
372376
None => Ok(None),
373377
}
@@ -388,13 +392,12 @@ mod tests {
388392
use std::collections::HashMap;
389393

390394
use scuffle_bytes_util::StringCow;
395+
#[cfg(feature = "serde")]
396+
use serde::Deserialize;
391397

392398
use super::Amf0Value;
393399
use crate::{Amf0Array, Amf0Decoder, Amf0Encoder, Amf0Error, Amf0Marker, Amf0Object};
394400

395-
#[cfg(feature = "serde")]
396-
use serde::Deserialize;
397-
398401
#[test]
399402
fn from() {
400403
let value: Amf0Value = 1.0.into();

0 commit comments

Comments
 (0)