Skip to content

Commit 44a4c69

Browse files
authored
Merge pull request #524 from Mingun/serde
Fix #473: add explicit serde feature that is independent from dependency
2 parents e877f4f + c205f1d commit 44a4c69

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

Cargo.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,21 @@ escape-html = []
164164
## [`Deserializer`]: crate::de::Deserializer
165165
overlapped-lists = []
166166

167-
## Enables support for [`serde`] serialization and deserialization
168-
serialize = ["serde"]
167+
## Enables serialization of some types using [`serde`]. Probably your rarely will
168+
## need this feature enabled.
169+
##
170+
## This feature does NOT provide XML serializer or deserializer. You should use
171+
## the `serialize` feature for that instead.
172+
# Cannot name "serde" to avoid clash with dependency.
173+
# "dep:" prefix only avalible from Rust 1.60
174+
serde-types = ["serde/derive"]
175+
176+
## Enables support for [`serde`] serialization and deserialization. When this
177+
## feature is enabled, quick-xml provides serializer and deserializer for XML.
178+
##
179+
## This feature does NOT enables serializaton of the types inside quick-xml.
180+
## If you need that, use the `serde-types` feature.
181+
serialize = ["serde"] # "dep:" prefix only avalible from Rust 1.60
169182

170183
[package.metadata.docs.rs]
171184
# document all features

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
```
4141
- [#523]: Fix incorrect handling of `xs:list`s with encoded spaces: they still
4242
act as delimiters, which is confirmed also by mature XmlBeans Java library
43+
- [#473]: Fix a hidden requirement to enable serde's `derive` feature to get
44+
quick-xml's `serialize` feature for `edition = 2021` or `resolver = 2` crates
4345

4446
### Misc Changes
4547

@@ -65,7 +67,9 @@
6567

6668
Refer to [documentation] for details.
6769
- [#521]: MSRV bumped to 1.52.
70+
- [#473]: `serde` feature that used to make some types serializable, renamed to `serde-types`
6871

72+
[#473]: https://github.com/tafia/quick-xml/issues/473
6973
[#490]: https://github.com/tafia/quick-xml/pull/490
7074
[#500]: https://github.com/tafia/quick-xml/issues/500
7175
[#514]: https://github.com/tafia/quick-xml/issues/514

src/name.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::fmt::{self, Debug, Formatter};
1616
///
1717
/// [qualified name]: https://www.w3.org/TR/xml-names11/#dt-qualname
1818
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
19-
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
19+
#[cfg_attr(feature = "serde-types", derive(serde::Deserialize, serde::Serialize))]
2020
pub struct QName<'a>(pub &'a [u8]);
2121
impl<'a> QName<'a> {
2222
/// Converts this name to an internal slice representation.
@@ -133,7 +133,7 @@ impl<'a> AsRef<[u8]> for QName<'a> {
133133
///
134134
/// [local (unqualified) name]: https://www.w3.org/TR/xml-names11/#dt-localname
135135
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
136-
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
136+
#[cfg_attr(feature = "serde-types", derive(serde::Deserialize, serde::Serialize))]
137137
pub struct LocalName<'a>(&'a [u8]);
138138
impl<'a> LocalName<'a> {
139139
/// Converts this name to an internal slice representation.
@@ -183,7 +183,7 @@ impl<'a> From<QName<'a>> for LocalName<'a> {
183183
///
184184
/// [namespace prefix]: https://www.w3.org/TR/xml-names11/#dt-prefix
185185
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
186-
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
186+
#[cfg_attr(feature = "serde-types", derive(serde::Deserialize, serde::Serialize))]
187187
pub struct Prefix<'a>(&'a [u8]);
188188
impl<'a> Prefix<'a> {
189189
/// Extracts internal slice
@@ -225,7 +225,7 @@ pub enum PrefixDeclaration<'a> {
225225
///
226226
/// [namespace name]: https://www.w3.org/TR/xml-names11/#dt-NSName
227227
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
228-
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
228+
#[cfg_attr(feature = "serde-types", derive(serde::Deserialize, serde::Serialize))]
229229
pub struct Namespace<'a>(pub &'a [u8]);
230230
impl<'a> Namespace<'a> {
231231
/// Converts this namespace to an internal slice representation.

0 commit comments

Comments
 (0)