diff --git a/Cargo.toml b/Cargo.toml
index b8299b91..41189800 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,7 +16,7 @@ include = ["src/*", "LICENSE-MIT.md", "README.md"]
[dependencies]
document-features = { version = "0.2", optional = true }
encoding_rs = { version = "0.8", optional = true }
-serde = { version = ">=1.0.100", optional = true }
+serde = { version = ">=1.0.139", optional = true }
tokio = { version = "1.10", optional = true, default-features = false, features = ["io-util"] }
memchr = "2.1"
arbitrary = { version = "1", features = ["derive"], optional = true }
diff --git a/Changelog.md b/Changelog.md
index f416a712..60403bd4 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -16,6 +16,10 @@
### Misc Changes
+- [#675]: Minimum supported version of serde raised to 1.0.139
+
+[#675]: https://github.com/tafia/quick-xml/pull/675
+
## 0.31.0 -- 2023-10-22
diff --git a/src/de/mod.rs b/src/de/mod.rs
index 90a104e0..f0c9da7b 100644
--- a/src/de/mod.rs
+++ b/src/de/mod.rs
@@ -509,8 +509,9 @@
//! /// Use unit variant, if you do not care of a content.
//! /// You can use tuple variant if you want to parse
//! /// textual content as an xs:list.
-//! /// Struct variants are not supported and will return
-//! /// Err(Unsupported)
+//! /// Struct variants are will pass a string to the
+//! /// struct enum variant visitor, which typically
+//! /// returns Err(Custom)
//! #[serde(rename = "$text")]
//! Text(String),
//! }
@@ -613,8 +614,9 @@
//! /// Use unit variant, if you do not care of a content.
//! /// You can use tuple variant if you want to parse
//! /// textual content as an xs:list.
-//! /// Struct variants are not supported and will return
-//! /// Err(Unsupported)
+//! /// Struct variants are will pass a string to the
+//! /// struct enum variant visitor, which typically
+//! /// returns Err(Custom)
//! #[serde(rename = "$text")]
//! Text(String),
//! }
@@ -1377,9 +1379,9 @@
//! |Kind |Top-level and in `$value` field |In normal field |In `$text` field |
//! |-------|-----------------------------------------|---------------------|---------------------|
//! |Unit |`` |`Unit`|`Unit` |
-//! |Newtype|`42` |Err(Unsupported) |Err(Unsupported) |
-//! |Tuple |`42answer` |Err(Unsupported) |Err(Unsupported) |
-//! |Struct |`42
answer`|Err(Unsupported) |Err(Unsupported) |
+//! |Newtype|`42` |Err(Custom) [^0] |Err(Custom) [^0] |
+//! |Tuple |`42answer` |Err(Custom) [^0] |Err(Custom) [^0] |
+//! |Struct |`42
answer`|Err(Custom) [^0] |Err(Custom) [^0] |
//!
//! `$text` enum variant
//! --------------------
@@ -1387,9 +1389,13 @@
//! |Kind |Top-level and in `$value` field |In normal field |In `$text` field |
//! |-------|-----------------------------------------|---------------------|---------------------|
//! |Unit |_(empty)_ |`` |_(empty)_ |
-//! |Newtype|`42` |Err(Unsupported) [^1]|Err(Unsupported) [^2]|
-//! |Tuple |`42 answer` |Err(Unsupported) [^3]|Err(Unsupported) [^4]|
-//! |Struct |Err(Unsupported) |Err(Unsupported) |Err(Unsupported) |
+//! |Newtype|`42` |Err(Custom) [^0] [^1]|Err(Custom) [^0] [^2]|
+//! |Tuple |`42 answer` |Err(Custom) [^0] [^3]|Err(Custom) [^0] [^4]|
+//! |Struct |Err(Custom) [^0] |Err(Custom) [^0] |Err(Custom) [^0] |
+//!
+//! [^0]: Error is returned by the deserialized type. In case of derived implementation a `Custom`
+//! error will be returned, but custom deserialize implementation can successfully deserialize
+//! value from a string which will be passed to it.
//!
//! [^1]: If this serialize as `42` then it will be ambiguity during deserialization,
//! because it clash with `Unit` representation in normal field.
diff --git a/src/de/simple_type.rs b/src/de/simple_type.rs
index 52fb7410..10c38310 100644
--- a/src/de/simple_type.rs
+++ b/src/de/simple_type.rs
@@ -9,6 +9,7 @@ use crate::errors::serialize::DeError;
use crate::escape::unescape;
use crate::utils::CowRef;
use memchr::memchr;
+use serde::de::value::UnitDeserializer;
use serde::de::{DeserializeSeed, Deserializer, EnumAccess, SeqAccess, VariantAccess, Visitor};
use serde::{self, serde_if_integer128};
use std::borrow::Cow;
@@ -40,15 +41,17 @@ macro_rules! unsupported {
$(
($($type:ty),*)
)?
- => $message:literal
) => {
#[inline]
fn $deserialize>(
self,
$($(_: $type,)*)?
- _visitor: V
+ visitor: V
) -> Result {
- Err(DeError::Unsupported($message.into()))
+ // Deserializer methods are only hints, if deserializer could not satisfy
+ // request, it should return the data that it has. It is responsibility
+ // of a Visitor to return an error if it does not understand the data
+ self.deserialize_str(visitor)
}
};
}
@@ -138,7 +141,8 @@ impl<'de, 'a> Content<'de, 'a> {
///
/// Identifiers represented as strings and deserialized accordingly.
///
-/// Deserialization of all other types returns [`Unsupported`][DeError::Unsupported] error.
+/// Deserialization of all other types will provide a string and in most cases
+/// the deserialization will fail because visitor does not expect that.
///
/// The `Owned` variant of the content acts as a storage for data, allocated by
/// an external deserializer that pass it via [`ListIter`].
@@ -305,71 +309,68 @@ impl<'de, 'a> Deserializer<'de> for AtomicDeserializer<'de, 'a> {
visitor.visit_unit()
}
- unsupported!(deserialize_bytes => "byte arrays are not supported as `xs:list` items");
- unsupported!(deserialize_byte_buf => "byte arrays are not supported as `xs:list` items");
- unsupported!(deserialize_seq => "sequences are not supported as `xs:list` items");
- unsupported!(deserialize_tuple(usize) => "tuples are not supported as `xs:list` items");
- unsupported!(deserialize_tuple_struct(&'static str, usize) => "tuples are not supported as `xs:list` items");
- unsupported!(deserialize_map => "maps are not supported as `xs:list` items");
- unsupported!(deserialize_struct(&'static str, &'static [&'static str]) => "structures are not supported as `xs:list` items");
+ unsupported!(deserialize_bytes);
+ unsupported!(deserialize_byte_buf);
+ unsupported!(deserialize_seq);
+ unsupported!(deserialize_tuple(usize));
+ unsupported!(deserialize_tuple_struct(&'static str, usize));
+ unsupported!(deserialize_map);
+ unsupported!(deserialize_struct(&'static str, &'static [&'static str]));
}
impl<'de, 'a> EnumAccess<'de> for AtomicDeserializer<'de, 'a> {
type Error = DeError;
- type Variant = AtomicUnitOnly;
+ type Variant = UnitOnly;
fn variant_seed(self, seed: V) -> Result<(V::Value, Self::Variant), DeError>
where
V: DeserializeSeed<'de>,
{
let name = seed.deserialize(self)?;
- Ok((name, AtomicUnitOnly))
+ Ok((name, UnitOnly))
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Deserializer of variant data, that supports only unit variants.
-/// Attempt to deserialize newtype, tuple or struct variant will return a
-/// [`DeError::Unsupported`] error.
-pub struct AtomicUnitOnly;
-impl<'de> VariantAccess<'de> for AtomicUnitOnly {
+/// Attempt to deserialize newtype will provide [`UnitDeserializer`].
+/// Attempt to deserialize tuple or struct variant will result to call of
+/// [`Visitor::visit_unit`].
+pub struct UnitOnly;
+impl<'de> VariantAccess<'de> for UnitOnly {
type Error = DeError;
#[inline]
- fn unit_variant(self) -> Result<(), DeError> {
+ fn unit_variant(self) -> Result<(), Self::Error> {
Ok(())
}
- fn newtype_variant_seed(self, _seed: T) -> Result
+ fn newtype_variant_seed(self, seed: T) -> Result
where
T: DeserializeSeed<'de>,
{
- Err(DeError::Unsupported(
- "enum newtype variants are not supported as `xs:list` items".into(),
- ))
+ seed.deserialize(UnitDeserializer::::new())
}
- fn tuple_variant(self, _len: usize, _visitor: V) -> Result
+ #[inline]
+ fn tuple_variant(self, _len: usize, visitor: V) -> Result
where
V: Visitor<'de>,
{
- Err(DeError::Unsupported(
- "enum tuple variants are not supported as `xs:list` items".into(),
- ))
+ visitor.visit_unit()
}
+ #[inline]
fn struct_variant(
self,
_fields: &'static [&'static str],
- _visitor: V,
- ) -> Result
+ visitor: V,
+ ) -> Result
where
V: Visitor<'de>,
{
- Err(DeError::Unsupported(
- "enum struct variants are not supported as `xs:list` items".into(),
- ))
+ visitor.visit_unit()
}
}
@@ -498,10 +499,11 @@ impl<'de, 'a> SeqAccess<'de> for ListIter<'de, 'a> {
/// - sequences, tuples and tuple structs are deserialized as `xs:list`s. Only
/// sequences of primitive types is possible to deserialize this way and they
/// should be delimited by a space (` `, `\t`, `\r`, or `\n`);
-/// - structs and maps returns [`DeError::Unsupported`];
+/// - structs and maps delegates to [`Self::deserialize_str`];
/// - enums:
/// - unit variants: just return `()`;
-/// - all other variants returns [`DeError::Unsupported`];
+/// - newtype variants: deserialize from [`UnitDeserializer`];
+/// - tuple and struct variants: call [`Visitor::visit_unit`];
/// - identifiers are deserialized as strings.
///
/// [simple types]: https://www.w3.org/TR/xmlschema11-1/#Simple_Type_Definition
@@ -615,6 +617,7 @@ impl<'de, 'a> Deserializer<'de> for SimpleTypeDeserializer<'de, 'a> {
deserialize_num!(deserialize_f64 => visit_f64);
/// Forwards deserialization to the [`Self::deserialize_str`]
+ #[inline]
fn deserialize_char(self, visitor: V) -> Result
where
V: Visitor<'de>,
@@ -638,6 +641,7 @@ impl<'de, 'a> Deserializer<'de> for SimpleTypeDeserializer<'de, 'a> {
}
/// Forwards deserialization to the [`Self::deserialize_str`]
+ #[inline]
fn deserialize_string(self, visitor: V) -> Result
where
V: Visitor<'de>,
@@ -645,17 +649,17 @@ impl<'de, 'a> Deserializer<'de> for SimpleTypeDeserializer<'de, 'a> {
self.deserialize_str(visitor)
}
- /// Returns [`DeError::Unsupported`]
- fn deserialize_bytes(self, _visitor: V) -> Result
+ /// Forwards deserialization to the [`Self::deserialize_str`]
+ #[inline]
+ fn deserialize_bytes(self, visitor: V) -> Result
where
V: Visitor<'de>,
{
- Err(DeError::Unsupported(
- "binary data content is not supported by XML format".into(),
- ))
+ self.deserialize_str(visitor)
}
- /// Forwards deserialization to the [`Self::deserialize_bytes`]
+ /// Forwards deserialization to the [`Self::deserialize_str`]
+ #[inline]
fn deserialize_byte_buf(self, visitor: V) -> Result
where
V: Visitor<'de>,
@@ -670,6 +674,7 @@ impl<'de, 'a> Deserializer<'de> for SimpleTypeDeserializer<'de, 'a> {
visitor.visit_some(self)
}
+ #[inline]
fn deserialize_unit(self, visitor: V) -> Result
where
V: Visitor<'de>,
@@ -678,6 +683,7 @@ impl<'de, 'a> Deserializer<'de> for SimpleTypeDeserializer<'de, 'a> {
}
/// Forwards deserialization to the [`Self::deserialize_unit`]
+ #[inline]
fn deserialize_unit_struct(
self,
_name: &'static str,
@@ -711,6 +717,7 @@ impl<'de, 'a> Deserializer<'de> for SimpleTypeDeserializer<'de, 'a> {
}
/// Representation of tuples the same as [sequences][Self::deserialize_seq].
+ #[inline]
fn deserialize_tuple(self, _len: usize, visitor: V) -> Result
where
V: Visitor<'de>,
@@ -719,6 +726,7 @@ impl<'de, 'a> Deserializer<'de> for SimpleTypeDeserializer<'de, 'a> {
}
/// Representation of named tuples the same as [unnamed tuples][Self::deserialize_tuple].
+ #[inline]
fn deserialize_tuple_struct(
self,
_name: &'static str,
@@ -731,9 +739,8 @@ impl<'de, 'a> Deserializer<'de> for SimpleTypeDeserializer<'de, 'a> {
self.deserialize_tuple(len, visitor)
}
- unsupported!(deserialize_map => "maps are not supported for XSD `simpleType`s");
- unsupported!(deserialize_struct(&'static str, &'static [&'static str])
- => "structures are not supported for XSD `simpleType`s");
+ unsupported!(deserialize_map);
+ unsupported!(deserialize_struct(&'static str, &'static [&'static str]));
fn deserialize_enum(
self,
@@ -748,6 +755,7 @@ impl<'de, 'a> Deserializer<'de> for SimpleTypeDeserializer<'de, 'a> {
}
/// Forwards deserialization to the [`Self::deserialize_str`]
+ #[inline]
fn deserialize_identifier(self, visitor: V) -> Result
where
V: Visitor<'de>,
@@ -755,6 +763,7 @@ impl<'de, 'a> Deserializer<'de> for SimpleTypeDeserializer<'de, 'a> {
self.deserialize_str(visitor)
}
+ #[inline]
fn deserialize_ignored_any(self, visitor: V) -> Result
where
V: Visitor<'de>,
@@ -765,60 +774,14 @@ impl<'de, 'a> Deserializer<'de> for SimpleTypeDeserializer<'de, 'a> {
impl<'de, 'a> EnumAccess<'de> for SimpleTypeDeserializer<'de, 'a> {
type Error = DeError;
- type Variant = SimpleTypeUnitOnly;
+ type Variant = UnitOnly;
fn variant_seed(self, seed: V) -> Result<(V::Value, Self::Variant), DeError>
where
V: DeserializeSeed<'de>,
{
let name = seed.deserialize(self)?;
- Ok((name, SimpleTypeUnitOnly))
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-/// Deserializer of variant data, that supports only unit variants.
-/// Attempt to deserialize newtype, tuple or struct variant will return a
-/// [`DeError::Unsupported`] error.
-pub struct SimpleTypeUnitOnly;
-impl<'de> VariantAccess<'de> for SimpleTypeUnitOnly {
- type Error = DeError;
-
- #[inline]
- fn unit_variant(self) -> Result<(), DeError> {
- Ok(())
- }
-
- fn newtype_variant_seed(self, _seed: T) -> Result
- where
- T: DeserializeSeed<'de>,
- {
- Err(DeError::Unsupported(
- "enum newtype variants are not supported for XSD `simpleType`s".into(),
- ))
- }
-
- fn tuple_variant(self, _len: usize, _visitor: V) -> Result
- where
- V: Visitor<'de>,
- {
- Err(DeError::Unsupported(
- "enum tuple variants are not supported for XSD `simpleType`s".into(),
- ))
- }
-
- fn struct_variant(
- self,
- _fields: &'static [&'static str],
- _visitor: V,
- ) -> Result
- where
- V: Visitor<'de>,
- {
- Err(DeError::Unsupported(
- "enum struct variants are not supported for XSD `simpleType`s".into(),
- ))
+ Ok((name, UnitOnly))
}
}
@@ -1046,9 +1009,9 @@ mod tests {
=> Custom("invalid type: string \"escaped string\", expected a borrowed string"));
err!(byte_buf: ByteBuf = "<escaped string"
- => Unsupported("byte arrays are not supported as `xs:list` items"));
+ => Custom("invalid type: string \" Unsupported("byte arrays are not supported as `xs:list` items"));
+ => Custom("invalid type: string \"non-escaped string\", expected borrowed bytes"));
deserialized_to!(option_none: Option<&str> = "" => None);
deserialized_to!(option_some: Option<&str> = "non-escaped-string" => Some("non-escaped-string"));
@@ -1063,24 +1026,24 @@ mod tests {
=> BorrowedNewtype("non-escaped string"));
err!(seq: Vec<()> = "non-escaped string"
- => Unsupported("sequences are not supported as `xs:list` items"));
+ => Custom("invalid type: string \"non-escaped string\", expected a sequence"));
err!(tuple: ((), ()) = "non-escaped string"
- => Unsupported("tuples are not supported as `xs:list` items"));
+ => Custom("invalid type: string \"non-escaped string\", expected a tuple of size 2"));
err!(tuple_struct: Tuple = "non-escaped string"
- => Unsupported("tuples are not supported as `xs:list` items"));
+ => Custom("invalid type: string \"non-escaped string\", expected tuple struct Tuple"));
err!(map: HashMap<(), ()> = "non-escaped string"
- => Unsupported("maps are not supported as `xs:list` items"));
+ => Custom("invalid type: string \"non-escaped string\", expected a map"));
err!(struct_: Struct = "non-escaped string"
- => Unsupported("structures are not supported as `xs:list` items"));
+ => Custom("invalid type: string \"non-escaped string\", expected struct Struct"));
deserialized_to!(enum_unit: Enum = "Unit" => Enum::Unit);
err!(enum_newtype: Enum = "Newtype"
- => Unsupported("enum newtype variants are not supported as `xs:list` items"));
+ => Custom("invalid type: unit value, expected a string"));
err!(enum_tuple: Enum = "Tuple"
- => Unsupported("enum tuple variants are not supported as `xs:list` items"));
+ => Custom("invalid type: unit value, expected tuple variant Enum::Tuple"));
err!(enum_struct: Enum = "Struct"
- => Unsupported("enum struct variants are not supported as `xs:list` items"));
+ => Custom("invalid type: unit value, expected struct variant Enum::Struct"));
err!(enum_other: Enum = "any data"
=> Custom("unknown variant `any data`, expected one of `Unit`, `Newtype`, `Tuple`, `Struct`"));
@@ -1240,11 +1203,11 @@ mod tests {
simple!(utf8, string: String = "<escaped string" => " Unsupported("binary data content is not supported by XML format"));
+ => Custom("invalid type: string \" "non-escaped string");
err!(utf8, borrowed_bytes: Bytes = "<escaped string"
- => Unsupported("binary data content is not supported by XML format"));
+ => Custom("invalid type: string \" = "" => Some(""));
simple!(utf8, option_some: Option<&str> = "non-escaped string" => Some("non-escaped string"));
@@ -1262,17 +1225,17 @@ mod tests {
=> BorrowedNewtype("non-escaped string"));
err!(utf8, map: HashMap<(), ()> = "any data"
- => Unsupported("maps are not supported for XSD `simpleType`s"));
+ => Custom("invalid type: string \"any data\", expected a map"));
err!(utf8, struct_: Struct = "any data"
- => Unsupported("structures are not supported for XSD `simpleType`s"));
+ => Custom("invalid type: string \"any data\", expected struct Struct"));
simple!(utf8, enum_unit: Enum = "Unit" => Enum::Unit);
err!(utf8, enum_newtype: Enum = "Newtype"
- => Unsupported("enum newtype variants are not supported for XSD `simpleType`s"));
+ => Custom("invalid type: unit value, expected a string"));
err!(utf8, enum_tuple: Enum = "Tuple"
- => Unsupported("enum tuple variants are not supported for XSD `simpleType`s"));
+ => Custom("invalid type: unit value, expected tuple variant Enum::Tuple"));
err!(utf8, enum_struct: Enum = "Struct"
- => Unsupported("enum struct variants are not supported for XSD `simpleType`s"));
+ => Custom("invalid type: unit value, expected struct variant Enum::Struct"));
err!(utf8, enum_other: Enum = "any data"
=> Custom("unknown variant `any data`, expected one of `Unit`, `Newtype`, `Tuple`, `Struct`"));
@@ -1301,7 +1264,7 @@ mod tests {
macro_rules! unsupported {
($name:ident: $type:ty = $xml:literal => $err:literal) => {
- err!(utf16, $name: $type = to_utf16($xml) => Unsupported($err));
+ err!(utf16, $name: $type = to_utf16($xml) => Custom($err));
};
}
@@ -1330,7 +1293,7 @@ mod tests {
utf16!(string: String = "<escaped string" => " "binary data content is not supported by XML format");
+ => "invalid type: string \" = "" => Some(()));
utf16!(option_some: Option<()> = "any data" => Some(()));
@@ -1341,23 +1304,23 @@ mod tests {
utf16!(newtype_owned: Newtype = "<escaped string" => Newtype(" Custom("invalid type: string \"non-escaped string\", expected a borrowed string"));
+ unsupported!(newtype_borrowed: BorrowedNewtype = "non-escaped string"
+ => "invalid type: string \"non-escaped string\", expected a borrowed string");
unsupported!(map: HashMap<(), ()> = "any data"
- => "maps are not supported for XSD `simpleType`s");
+ => "invalid type: string \"any data\", expected a map");
unsupported!(struct_: Struct = "any data"
- => "structures are not supported for XSD `simpleType`s");
+ => "invalid type: string \"any data\", expected struct Struct");
utf16!(enum_unit: Enum = "Unit" => Enum::Unit);
unsupported!(enum_newtype: Enum = "Newtype"
- => "enum newtype variants are not supported for XSD `simpleType`s");
+ => "invalid type: unit value, expected a string");
unsupported!(enum_tuple: Enum = "Tuple"
- => "enum tuple variants are not supported for XSD `simpleType`s");
+ => "invalid type: unit value, expected tuple variant Enum::Tuple");
unsupported!(enum_struct: Enum = "Struct"
- => "enum struct variants are not supported for XSD `simpleType`s");
- err!(utf16, enum_other: Enum = to_utf16("any data")
- => Custom("unknown variant `any data`, expected one of `Unit`, `Newtype`, `Tuple`, `Struct`"));
+ => "invalid type: unit value, expected struct variant Enum::Struct");
+ unsupported!(enum_other: Enum = "any data"
+ => "unknown variant `any data`, expected one of `Unit`, `Newtype`, `Tuple`, `Struct`");
utf16!(identifier: Id = "Field" => Id::Field);
utf16!(ignored_any: Any = "any data" => Any(IgnoredAny));
diff --git a/tests/serde-de-enum.rs b/tests/serde-de-enum.rs
index 4b66b0cc..82028004 100644
--- a/tests/serde-de-enum.rs
+++ b/tests/serde-de-enum.rs
@@ -320,6 +320,7 @@ mod externally_tagged {
/// Struct variant cannot be directly deserialized from `Text` / `CData` events
mod struct_ {
use super::*;
+ use pretty_assertions::assert_eq;
#[derive(Debug, Deserialize, PartialEq)]
enum Text {
@@ -330,24 +331,42 @@ mod externally_tagged {
#[test]
fn text() {
match from_str::(" text ") {
- Err(DeError::Unsupported(_)) => {}
- x => panic!("Expected `Err(Unsupported(_))`, but got `{:?}`", x),
+ Err(DeError::Custom(reason)) => assert_eq!(
+ reason,
+ "invalid type: string \"text\", expected struct variant Text::Struct"
+ ),
+ x => panic!(
+ r#"Expected `Err(Custom("invalid type: string \"text\", expected struct variant Text::Struct"))`, but got `{:?}`"#,
+ x
+ ),
}
}
#[test]
fn cdata() {
match from_str::("") {
- Err(DeError::Unsupported(_)) => {}
- x => panic!("Expected `Err(Unsupported(_))`, but got `{:?}`", x),
+ Err(DeError::Custom(reason)) => assert_eq!(
+ reason,
+ "invalid type: string \" cdata \", expected struct variant Text::Struct"
+ ),
+ x => panic!(
+ r#"Expected `Err(Custom("invalid type: string \" cdata \", expected struct variant Text::Struct"))`, but got `{:?}`"#,
+ x
+ ),
}
}
#[test]
fn mixed() {
match from_str::(" te xt ") {
- Err(DeError::Unsupported(_)) => {}
- x => panic!("Expected `Err(Unsupported(_))`, but got `{:?}`", x),
+ Err(DeError::Custom(reason)) => assert_eq!(
+ reason,
+ "invalid type: string \"te cdata xt\", expected struct variant Text::Struct"
+ ),
+ x => panic!(
+ r#"Expected `Err(Custom("invalid type: string \"te cdata xt\", expected struct variant Text::Struct"))`, but got `{:?}`"#,
+ x
+ ),
}
}
}
diff --git a/tests/serde-de.rs b/tests/serde-de.rs
index 59f30172..09338edb 100644
--- a/tests/serde-de.rs
+++ b/tests/serde-de.rs
@@ -354,11 +354,11 @@ mod trivial {
#[test]
fn byte_buf() {
match from_str::>("escaped byte_buf") {
- Err(DeError::Unsupported(msg)) => {
- assert_eq!(msg, "binary data content is not supported by XML format")
+ Err(DeError::Custom(msg)) => {
+ assert_eq!(msg, "invalid type: string \"escaped byte_buf\", expected byte data")
}
x => panic!(
- r#"Expected `Err(Unsupported("binary data content is not supported by XML format"))`, but got `{:?}`"#,
+ r#"Expected `Err(Custom("invalid type: string \"escaped byte_buf\", expected byte data"))`, but got `{:?}`"#,
x
),
}
@@ -368,11 +368,11 @@ mod trivial {
#[test]
fn bytes() {
match from_str::>("escaped byte_buf") {
- Err(DeError::Unsupported(msg)) => {
- assert_eq!(msg, "binary data content is not supported by XML format")
+ Err(DeError::Custom(msg)) => {
+ assert_eq!(msg, "invalid type: string \"escaped byte_buf\", expected borrowed bytes")
}
x => panic!(
- r#"Expected `Err(Unsupported("binary data content is not supported by XML format"))`, but got `{:?}`"#,
+ r#"Expected `Err(Custom("invalid type: string \"escaped byte_buf\", expected borrowed bytes"))`, but got `{:?}`"#,
x
),
}
@@ -417,11 +417,11 @@ mod trivial {
#[test]
fn byte_buf() {
match from_str::>("") {
- Err(DeError::Unsupported(msg)) => {
- assert_eq!(msg, "binary data content is not supported by XML format")
+ Err(DeError::Custom(msg)) => {
+ assert_eq!(msg, "invalid type: string \"escaped byte_buf\", expected byte data")
}
x => panic!(
- r#"Expected `Err(Unsupported("binary data content is not supported by XML format"))`, but got `{:?}`"#,
+ r#"Expected `Err(Custom("invalid type: string \"escaped byte_buf\", expected byte data"))`, but got `{:?}`"#,
x
),
}
@@ -431,11 +431,11 @@ mod trivial {
#[test]
fn bytes() {
match from_str::>("") {
- Err(DeError::Unsupported(msg)) => {
- assert_eq!(msg, "binary data content is not supported by XML format")
+ Err(DeError::Custom(msg)) => {
+ assert_eq!(msg, "invalid type: string \"escaped byte_buf\", expected borrowed bytes")
}
x => panic!(
- r#"Expected `Err(Unsupported("binary data content is not supported by XML format"))`, but got `{:?}`"#,
+ r#"Expected `Err(Custom("invalid type: string \"escaped byte_buf\", expected borrowed bytes"))`, but got `{:?}`"#,
x
),
}
@@ -1158,7 +1158,7 @@ mod xml_schema_lists {
"third 3".to_string(),
]);
err!(byte_buf: ByteBuf = r#""#
- => Unsupported("byte arrays are not supported as `xs:list` items"));
+ => Custom("invalid type: string \"first\", expected byte data"));
list!(unit: () = r#""# => vec![(), (), ()]);
}
@@ -1209,7 +1209,7 @@ mod xml_schema_lists {
"3".to_string(),
]);
err!(byte_buf: ByteBuf = "first second third 3"
- => Unsupported("byte arrays are not supported as `xs:list` items"));
+ => Custom("invalid type: string \"first\", expected byte data"));
list!(unit: () = "1 second false" => vec![(), (), ()]);
}
@@ -1248,7 +1248,7 @@ mod xml_schema_lists {
"third 3".to_string(),
]);
err!(byte_buf: ByteBuf = "first second third 3"
- => Unsupported("byte arrays are not supported as `xs:list` items"));
+ => Custom("invalid type: string \"first\", expected byte data"));
list!(unit: () = "1 second false" => vec![(), (), ()]);
}