From e2a6a1ceceb87e222ab1ed13309948157a4492d1 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 12 Sep 2023 15:09:39 -0500 Subject: [PATCH 1/6] test(serde): Verify existing variant behavior --- crates/toml/tests/testsuite/serde.rs | 86 ++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/crates/toml/tests/testsuite/serde.rs b/crates/toml/tests/testsuite/serde.rs index 13af51d8..ea6a8b01 100644 --- a/crates/toml/tests/testsuite/serde.rs +++ b/crates/toml/tests/testsuite/serde.rs @@ -376,6 +376,92 @@ fn parse_enum_string() { } } +#[test] +fn parse_tuple_variant() { + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] + struct Document { + inner: Vec, + } + + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] + enum Enum { + Int(i32, i32), + String(String, String), + } + + let input = Document { + inner: vec![ + Enum::Int(1, 1), + Enum::String("2".to_owned(), "2".to_owned()), + ], + }; + let expected = "inner = [[1, 1], [\"2\", \"2\"]] +"; + let raw = toml::to_string(&input).unwrap(); + snapbox::assert_eq(expected, raw); + + /* + equivalent! { + Document { + inner: vec![ + Enum::Int(1, 1), + Enum::String("2".to_owned(), "2".to_owned()), + ], + }, + map! { + inner: vec![ + map! { Int: [1, 1] }, + map! { String: ["2".to_owned(), "2".to_owned()] }, + ] + }, + }*/ +} + +#[test] +fn parse_struct_variant() { + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] + struct Document { + inner: Vec, + } + + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] + enum Enum { + Int { first: i32, second: i32 }, + String { first: String, second: String }, + } + + let input = Document { + inner: vec![ + Enum::Int { + first: 1, + second: 1, + }, + Enum::String { + first: "2".to_owned(), + second: "2".to_owned(), + }, + ], + }; + let err = toml::to_string(&input).unwrap_err(); + snapbox::assert_eq("unsupported Enum type", err.to_string()); + + /* + equivalent! { + Document { + inner: vec![ + Enum::Int { first: 1, second: 1 }, + Enum::String { first: "2".to_owned(), second: "2".to_owned() }, + ], + }, + map! { + inner: vec![ + map! { Int: map! { first: 1, second: 1 } }, + map! { String: map! { first: "2".to_owned(), second: "2".to_owned() } }, + ] + }, + }*/ +} + #[test] #[cfg(feature = "preserve_order")] fn map_key_unit_variants() { From 2b7c34c900aa2622660af495e126a75b71916cba Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 12 Sep 2023 17:09:40 -0500 Subject: [PATCH 2/6] test(serde): Focus on string serialization first --- crates/toml/tests/testsuite/serde.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/toml/tests/testsuite/serde.rs b/crates/toml/tests/testsuite/serde.rs index ea6a8b01..d8d3d84d 100644 --- a/crates/toml/tests/testsuite/serde.rs +++ b/crates/toml/tests/testsuite/serde.rs @@ -21,12 +21,6 @@ macro_rules! equivalent { let toml = $toml; let literal = $literal; - // In/out of Value is equivalent - println!("try_from"); - assert_eq!(t!(Table::try_from(literal.clone())), toml); - println!("try_into"); - assert_eq!(literal, t!(toml.clone().try_into())); - // Through a string equivalent println!("to_string"); snapbox::assert_eq(t!(toml::to_string(&toml)), t!(toml::to_string(&literal))); @@ -34,6 +28,12 @@ macro_rules! equivalent { assert_eq!(literal, t!(toml::from_str(&t!(toml::to_string(&toml))))); println!("toml, from_str(toml)"); assert_eq!(toml, t!(toml::from_str(&t!(toml::to_string(&toml))))); + + // In/out of Value is equivalent + println!("try_from"); + assert_eq!(t!(Table::try_from(literal.clone())), toml); + println!("try_into"); + assert_eq!(literal, t!(toml.clone().try_into())); }}; } From 4ffa44ec16155fa73120538eb993dd489552f3ea Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 12 Sep 2023 17:11:53 -0500 Subject: [PATCH 3/6] test(serde): Make parameter order more consistent --- crates/toml/tests/testsuite/serde.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/toml/tests/testsuite/serde.rs b/crates/toml/tests/testsuite/serde.rs index d8d3d84d..ffbef7aa 100644 --- a/crates/toml/tests/testsuite/serde.rs +++ b/crates/toml/tests/testsuite/serde.rs @@ -23,15 +23,15 @@ macro_rules! equivalent { // Through a string equivalent println!("to_string"); - snapbox::assert_eq(t!(toml::to_string(&toml)), t!(toml::to_string(&literal))); + snapbox::assert_eq(t!(toml::to_string(&literal)), t!(toml::to_string(&toml))); println!("literal, from_str(toml)"); assert_eq!(literal, t!(toml::from_str(&t!(toml::to_string(&toml))))); - println!("toml, from_str(toml)"); - assert_eq!(toml, t!(toml::from_str(&t!(toml::to_string(&toml))))); + println!("toml, from_str(literal)"); + assert_eq!(toml, t!(toml::from_str(&t!(toml::to_string(&literal))))); // In/out of Value is equivalent println!("try_from"); - assert_eq!(t!(Table::try_from(literal.clone())), toml); + assert_eq!(toml, t!(Table::try_from(literal.clone()))); println!("try_into"); assert_eq!(literal, t!(toml.clone().try_into())); }}; From cf06b83424921c7ca902bba9fa18d66088af764d Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 12 Sep 2023 18:53:05 -0600 Subject: [PATCH 4/6] test(serde): Verify both Table and Value serializers --- crates/toml/tests/testsuite/serde.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/toml/tests/testsuite/serde.rs b/crates/toml/tests/testsuite/serde.rs index ffbef7aa..8a9bad01 100644 --- a/crates/toml/tests/testsuite/serde.rs +++ b/crates/toml/tests/testsuite/serde.rs @@ -30,10 +30,17 @@ macro_rules! equivalent { assert_eq!(toml, t!(toml::from_str(&t!(toml::to_string(&literal))))); // In/out of Value is equivalent - println!("try_from"); + println!("Table::try_from(literal)"); assert_eq!(toml, t!(Table::try_from(literal.clone()))); - println!("try_into"); + println!("Value::try_from(literal)"); + assert_eq!( + Value::Table(toml.clone()), + t!(Value::try_from(literal.clone())) + ); + println!("toml.try_into()"); assert_eq!(literal, t!(toml.clone().try_into())); + println!("Value::Table(toml).try_into()"); + assert_eq!(literal, t!(Value::Table(toml.clone()).try_into())); }}; } From 88a4dba3123600016b2388439750198b6c57db13 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 12 Sep 2023 16:50:09 -0500 Subject: [PATCH 5/6] fix(serde): Support tuple variants as table of an array --- crates/toml/src/value.rs | 57 +++++++++++++++++++++++++-- crates/toml/tests/testsuite/serde.rs | 9 +++-- crates/toml_edit/src/de/table_enum.rs | 46 +++++++++++++++++++++ crates/toml_edit/src/ser/map.rs | 46 +++++++++++++++++++-- crates/toml_edit/src/ser/value.rs | 6 +-- 5 files changed, 152 insertions(+), 12 deletions(-) diff --git a/crates/toml/src/value.rs b/crates/toml/src/value.rs index 2785d9de..b1c7b829 100644 --- a/crates/toml/src/value.rs +++ b/crates/toml/src/value.rs @@ -770,6 +770,13 @@ impl<'de> serde::de::VariantAccess<'de> for MapEnumDeserializer { fn unit_variant(self) -> Result<(), Self::Error> { use de::Error; match self.value { + Value::Array(values) => { + if values.is_empty() { + Ok(()) + } else { + Err(Error::custom("expected empty array")) + } + } Value::Table(values) => { if values.is_empty() { Ok(()) @@ -797,6 +804,13 @@ impl<'de> serde::de::VariantAccess<'de> for MapEnumDeserializer { { use de::Error; match self.value { + Value::Array(values) => { + if values.len() == len { + serde::de::Deserializer::deserialize_seq(values.into_deserializer(), visitor) + } else { + Err(Error::custom(format!("expected tuple with length {}", len))) + } + } Value::Table(values) => { let tuple_values = values .into_iter() @@ -870,7 +884,7 @@ impl ser::Serializer for ValueSerializer { type SerializeSeq = ValueSerializeVec; type SerializeTuple = ValueSerializeVec; type SerializeTupleStruct = ValueSerializeVec; - type SerializeTupleVariant = ValueSerializeVec; + type SerializeTupleVariant = ValueSerializeTupleVariant; type SerializeMap = ValueSerializeMap; type SerializeStruct = ValueSerializeMap; type SerializeStructVariant = ser::Impossible; @@ -1015,10 +1029,10 @@ impl ser::Serializer for ValueSerializer { self, _name: &'static str, _variant_index: u32, - _variant: &'static str, + variant: &'static str, len: usize, ) -> Result { - self.serialize_seq(Some(len)) + Ok(ValueSerializeTupleVariant::tuple(variant, len)) } fn serialize_map(self, _len: Option) -> Result { @@ -1453,3 +1467,40 @@ impl<'a, 'de> de::Visitor<'de> for DatetimeOrTable<'a> { } } } + +type ValueSerializeTupleVariant = ValueSerializeVariant; + +struct ValueSerializeVariant { + variant: &'static str, + inner: T, +} + +impl ValueSerializeVariant { + pub(crate) fn tuple(variant: &'static str, len: usize) -> Self { + Self { + variant, + inner: ValueSerializeVec { + vec: Vec::with_capacity(len), + }, + } + } +} + +impl serde::ser::SerializeTupleVariant for ValueSerializeVariant { + type Ok = crate::Value; + type Error = crate::ser::Error; + + fn serialize_field(&mut self, value: &T) -> Result<(), Self::Error> + where + T: serde::ser::Serialize, + { + serde::ser::SerializeSeq::serialize_element(&mut self.inner, value) + } + + fn end(self) -> Result { + let inner = serde::ser::SerializeSeq::end(self.inner)?; + let mut table = Table::new(); + table.insert(self.variant.to_owned(), inner); + Ok(Value::Table(table)) + } +} diff --git a/crates/toml/tests/testsuite/serde.rs b/crates/toml/tests/testsuite/serde.rs index 8a9bad01..b7e00018 100644 --- a/crates/toml/tests/testsuite/serde.rs +++ b/crates/toml/tests/testsuite/serde.rs @@ -402,12 +402,15 @@ fn parse_tuple_variant() { Enum::String("2".to_owned(), "2".to_owned()), ], }; - let expected = "inner = [[1, 1], [\"2\", \"2\"]] + let expected = "[[inner]] +Int = [1, 1] + +[[inner]] +String = [\"2\", \"2\"] "; let raw = toml::to_string(&input).unwrap(); snapbox::assert_eq(expected, raw); - /* equivalent! { Document { inner: vec![ @@ -421,7 +424,7 @@ fn parse_tuple_variant() { map! { String: ["2".to_owned(), "2".to_owned()] }, ] }, - }*/ + } } #[test] diff --git a/crates/toml_edit/src/de/table_enum.rs b/crates/toml_edit/src/de/table_enum.rs index 197ad6ea..328834bf 100644 --- a/crates/toml_edit/src/de/table_enum.rs +++ b/crates/toml_edit/src/de/table_enum.rs @@ -16,6 +16,20 @@ impl<'de> serde::de::VariantAccess<'de> for TableEnumDeserializer { fn unit_variant(self) -> Result<(), Self::Error> { match self.value { + crate::Item::ArrayOfTables(values) => { + if values.is_empty() { + Ok(()) + } else { + Err(Error::custom("expected empty array", values.span())) + } + } + crate::Item::Value(crate::Value::Array(values)) => { + if values.is_empty() { + Ok(()) + } else { + Err(Error::custom("expected empty table", values.span())) + } + } crate::Item::Table(values) => { if values.is_empty() { Ok(()) @@ -49,6 +63,38 @@ impl<'de> serde::de::VariantAccess<'de> for TableEnumDeserializer { V: serde::de::Visitor<'de>, { match self.value { + crate::Item::ArrayOfTables(values) => { + let values_span = values.span(); + let tuple_values = values.values.into_iter().collect::>(); + + if tuple_values.len() == len { + serde::de::Deserializer::deserialize_seq( + super::ArrayDeserializer::new(tuple_values, values_span), + visitor, + ) + } else { + Err(Error::custom( + format!("expected tuple with length {}", len), + values_span, + )) + } + } + crate::Item::Value(crate::Value::Array(values)) => { + let values_span = values.span(); + let tuple_values = values.values.into_iter().collect::>(); + + if tuple_values.len() == len { + serde::de::Deserializer::deserialize_seq( + super::ArrayDeserializer::new(tuple_values, values_span), + visitor, + ) + } else { + Err(Error::custom( + format!("expected tuple with length {}", len), + values_span, + )) + } + } crate::Item::Table(values) => { let values_span = values.span(); let tuple_values = values diff --git a/crates/toml_edit/src/ser/map.rs b/crates/toml_edit/src/ser/map.rs index 951a5cb9..6721e160 100644 --- a/crates/toml_edit/src/ser/map.rs +++ b/crates/toml_edit/src/ser/map.rs @@ -1,4 +1,4 @@ -use super::{Error, KeySerializer, ValueSerializer}; +use super::{Error, KeySerializer, SerializeValueArray, ValueSerializer}; #[doc(hidden)] pub enum SerializeMap { @@ -165,7 +165,6 @@ impl serde::ser::SerializeMap for SerializeInlineTable { where T: serde::ser::Serialize, { - self.key = None; self.key = Some(input.serialize(KeySerializer)?); Ok(()) } @@ -423,7 +422,7 @@ impl serde::ser::Serializer for &mut MapValueSerializer { type SerializeSeq = super::SerializeValueArray; type SerializeTuple = super::SerializeValueArray; type SerializeTupleStruct = super::SerializeValueArray; - type SerializeTupleVariant = super::SerializeValueArray; + type SerializeTupleVariant = super::SerializeTupleVariant; type SerializeMap = super::SerializeMap; type SerializeStruct = super::SerializeMap; type SerializeStructVariant = serde::ser::Impossible; @@ -585,3 +584,44 @@ impl serde::ser::Serializer for &mut MapValueSerializer { ValueSerializer::new().serialize_struct_variant(name, variant_index, variant, len) } } + +pub type SerializeTupleVariant = SerializeVariant; + +pub struct SerializeVariant { + variant: &'static str, + inner: T, +} + +impl SerializeVariant { + pub(crate) fn tuple(variant: &'static str, len: usize) -> Self { + Self { + variant, + inner: SerializeValueArray::with_capacity(len), + } + } +} + +impl serde::ser::SerializeTupleVariant for SerializeVariant { + type Ok = crate::Value; + type Error = Error; + + fn serialize_field(&mut self, value: &T) -> Result<(), Error> + where + T: serde::ser::Serialize, + { + serde::ser::SerializeSeq::serialize_element(&mut self.inner, value) + } + + fn end(self) -> Result { + let inner = serde::ser::SerializeSeq::end(self.inner)?; + let mut items = crate::table::KeyValuePairs::new(); + let kv = crate::table::TableKeyValue::new( + crate::Key::new(self.variant), + crate::Item::Value(inner), + ); + items.insert(crate::InternalString::from(self.variant), kv); + Ok(crate::Value::InlineTable(crate::InlineTable::with_pairs( + items, + ))) + } +} diff --git a/crates/toml_edit/src/ser/value.rs b/crates/toml_edit/src/ser/value.rs index d29390a4..a094a85b 100644 --- a/crates/toml_edit/src/ser/value.rs +++ b/crates/toml_edit/src/ser/value.rs @@ -60,7 +60,7 @@ impl serde::ser::Serializer for ValueSerializer { type SerializeSeq = super::SerializeValueArray; type SerializeTuple = super::SerializeValueArray; type SerializeTupleStruct = super::SerializeValueArray; - type SerializeTupleVariant = super::SerializeValueArray; + type SerializeTupleVariant = super::SerializeTupleVariant; type SerializeMap = super::SerializeMap; type SerializeStruct = super::SerializeMap; type SerializeStructVariant = serde::ser::Impossible; @@ -205,10 +205,10 @@ impl serde::ser::Serializer for ValueSerializer { self, _name: &'static str, _variant_index: u32, - _variant: &'static str, + variant: &'static str, len: usize, ) -> Result { - self.serialize_seq(Some(len)) + Ok(super::SerializeTupleVariant::tuple(variant, len)) } fn serialize_map(self, len: Option) -> Result { From 58a7101f68ecacc7de1f711f1c25c7ea458c9fdd Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 12 Sep 2023 19:54:54 -0600 Subject: [PATCH 6/6] fix(serde): Support struct variants as table of a table --- crates/toml/src/value.rs | 46 +++++++++++++++++++++++++--- crates/toml/tests/testsuite/serde.rs | 19 +++++++++--- crates/toml_edit/src/ser/map.rs | 39 ++++++++++++++++++++++- crates/toml_edit/src/ser/value.rs | 10 +++--- 4 files changed, 99 insertions(+), 15 deletions(-) diff --git a/crates/toml/src/value.rs b/crates/toml/src/value.rs index b1c7b829..b98196ad 100644 --- a/crates/toml/src/value.rs +++ b/crates/toml/src/value.rs @@ -887,7 +887,7 @@ impl ser::Serializer for ValueSerializer { type SerializeTupleVariant = ValueSerializeTupleVariant; type SerializeMap = ValueSerializeMap; type SerializeStruct = ValueSerializeMap; - type SerializeStructVariant = ser::Impossible; + type SerializeStructVariant = ValueSerializeStructVariant; fn serialize_bool(self, value: bool) -> Result { Ok(Value::Boolean(value)) @@ -1054,12 +1054,12 @@ impl ser::Serializer for ValueSerializer { fn serialize_struct_variant( self, - name: &'static str, + _name: &'static str, _variant_index: u32, - _variant: &'static str, - _len: usize, + variant: &'static str, + len: usize, ) -> Result { - Err(crate::ser::Error::unsupported_type(Some(name))) + Ok(ValueSerializeStructVariant::struct_(variant, len)) } } @@ -1469,6 +1469,7 @@ impl<'a, 'de> de::Visitor<'de> for DatetimeOrTable<'a> { } type ValueSerializeTupleVariant = ValueSerializeVariant; +type ValueSerializeStructVariant = ValueSerializeVariant; struct ValueSerializeVariant { variant: &'static str, @@ -1486,6 +1487,20 @@ impl ValueSerializeVariant { } } +impl ValueSerializeVariant { + pub(crate) fn struct_(variant: &'static str, len: usize) -> Self { + Self { + variant, + inner: ValueSerializeMap { + ser: SerializeMap { + map: Table::with_capacity(len), + next_key: None, + }, + }, + } + } +} + impl serde::ser::SerializeTupleVariant for ValueSerializeVariant { type Ok = crate::Value; type Error = crate::ser::Error; @@ -1504,3 +1519,24 @@ impl serde::ser::SerializeTupleVariant for ValueSerializeVariant { + type Ok = crate::Value; + type Error = crate::ser::Error; + + #[inline] + fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error> + where + T: serde::ser::Serialize + ?Sized, + { + serde::ser::SerializeStruct::serialize_field(&mut self.inner, key, value) + } + + #[inline] + fn end(self) -> Result { + let inner = serde::ser::SerializeStruct::end(self.inner)?; + let mut table = Table::new(); + table.insert(self.variant.to_owned(), inner); + Ok(Value::Table(table)) + } +} diff --git a/crates/toml/tests/testsuite/serde.rs b/crates/toml/tests/testsuite/serde.rs index b7e00018..82ba00b1 100644 --- a/crates/toml/tests/testsuite/serde.rs +++ b/crates/toml/tests/testsuite/serde.rs @@ -452,10 +452,21 @@ fn parse_struct_variant() { }, ], }; - let err = toml::to_string(&input).unwrap_err(); - snapbox::assert_eq("unsupported Enum type", err.to_string()); + let expected = "[[inner]] + +[inner.Int] +first = 1 +second = 1 + +[[inner]] + +[inner.String] +first = \"2\" +second = \"2\" +"; + let raw = toml::to_string(&input).unwrap(); + snapbox::assert_eq(expected, raw); - /* equivalent! { Document { inner: vec![ @@ -469,7 +480,7 @@ fn parse_struct_variant() { map! { String: map! { first: "2".to_owned(), second: "2".to_owned() } }, ] }, - }*/ + } } #[test] diff --git a/crates/toml_edit/src/ser/map.rs b/crates/toml_edit/src/ser/map.rs index 6721e160..47e56ba4 100644 --- a/crates/toml_edit/src/ser/map.rs +++ b/crates/toml_edit/src/ser/map.rs @@ -425,7 +425,7 @@ impl serde::ser::Serializer for &mut MapValueSerializer { type SerializeTupleVariant = super::SerializeTupleVariant; type SerializeMap = super::SerializeMap; type SerializeStruct = super::SerializeMap; - type SerializeStructVariant = serde::ser::Impossible; + type SerializeStructVariant = super::SerializeStructVariant; fn serialize_bool(self, v: bool) -> Result { ValueSerializer::new().serialize_bool(v) @@ -586,6 +586,7 @@ impl serde::ser::Serializer for &mut MapValueSerializer { } pub type SerializeTupleVariant = SerializeVariant; +pub type SerializeStructVariant = SerializeVariant; pub struct SerializeVariant { variant: &'static str, @@ -601,6 +602,15 @@ impl SerializeVariant { } } +impl SerializeVariant { + pub(crate) fn struct_(variant: &'static str, len: usize) -> Self { + Self { + variant, + inner: SerializeMap::table_with_capacity(len), + } + } +} + impl serde::ser::SerializeTupleVariant for SerializeVariant { type Ok = crate::Value; type Error = Error; @@ -625,3 +635,30 @@ impl serde::ser::SerializeTupleVariant for SerializeVariant ))) } } + +impl serde::ser::SerializeStructVariant for SerializeVariant { + type Ok = crate::Value; + type Error = Error; + + #[inline] + fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error> + where + T: serde::ser::Serialize + ?Sized, + { + serde::ser::SerializeStruct::serialize_field(&mut self.inner, key, value) + } + + #[inline] + fn end(self) -> Result { + let inner = serde::ser::SerializeStruct::end(self.inner)?; + let mut items = crate::table::KeyValuePairs::new(); + let kv = crate::table::TableKeyValue::new( + crate::Key::new(self.variant), + crate::Item::Value(inner), + ); + items.insert(crate::InternalString::from(self.variant), kv); + Ok(crate::Value::InlineTable(crate::InlineTable::with_pairs( + items, + ))) + } +} diff --git a/crates/toml_edit/src/ser/value.rs b/crates/toml_edit/src/ser/value.rs index a094a85b..808bb900 100644 --- a/crates/toml_edit/src/ser/value.rs +++ b/crates/toml_edit/src/ser/value.rs @@ -63,7 +63,7 @@ impl serde::ser::Serializer for ValueSerializer { type SerializeTupleVariant = super::SerializeTupleVariant; type SerializeMap = super::SerializeMap; type SerializeStruct = super::SerializeMap; - type SerializeStructVariant = serde::ser::Impossible; + type SerializeStructVariant = super::SerializeStructVariant; fn serialize_bool(self, v: bool) -> Result { Ok(v.into()) @@ -233,11 +233,11 @@ impl serde::ser::Serializer for ValueSerializer { fn serialize_struct_variant( self, - name: &'static str, + _name: &'static str, _variant_index: u32, - _variant: &'static str, - _len: usize, + variant: &'static str, + len: usize, ) -> Result { - Err(Error::UnsupportedType(Some(name))) + Ok(super::SerializeStructVariant::struct_(variant, len)) } }