Skip to content

Commit 35f87c0

Browse files
authored
feat(quick-xml): Updates quick-xml to version 0.38.0. (#132)
* feat(quick-xml): Updates `quick-xml` to version `0.38.0`. * Fixes required to compile.
1 parent fd84715 commit 35f87c0

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xmlity-quick-xml/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ exclude.workspace = true
1414
[dependencies]
1515
thiserror.workspace = true
1616
xmlity.workspace = true
17-
quick-xml = { version = "0.37.4" }
17+
quick-xml = { version = "0.38.0" }
1818

1919

2020
[dev-dependencies]
@@ -23,7 +23,7 @@ rstest.workspace = true
2323
xmlity = { workspace = true, features = ["derive"] }
2424
criterion = { version = "0.5", features = ["html_reports"] }
2525
serde = { version = "1.0.210", features = ["derive"] }
26-
quick-xml = { version = "0.37.4", features = ["serialize"] }
26+
quick-xml = { version = "0.38.0", features = ["serialize"] }
2727
yaserde = { version = "0.12.0", features = ["derive"] }
2828
ntest = "0.9.3"
2929

xmlity-quick-xml/src/de.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ use crate::{xml_namespace_from_resolve_result, HasQuickXmlAlternative, OwnedQuic
2121

2222
/// Errors that can occur when using this crate.
2323
#[derive(Debug, thiserror::Error)]
24+
#[non_exhaustive]
2425
pub enum Error {
2526
/// Error from the `quick-xml` crate.
2627
#[error("Quick XML error: {0}")]
2728
QuickXml(#[from] quick_xml::Error),
29+
/// Error from the `quick-xml` crate when decoding references.
30+
#[error("Encoding error: {0}")]
31+
EncodingError(#[from] quick_xml::encoding::EncodingError),
2832
/// Error from the `quick-xml` crate when handling attributes.
2933
#[error("Attribute error: {0}")]
3034
AttrError(#[from] quick_xml::events::attributes::AttrError),
@@ -838,6 +842,36 @@ impl<'de> XmlText<'de> for DataWithD<'_, BytesText<'de>> {
838842
}
839843
}
840844

845+
impl<'de> XmlText<'de> for DataWithD<'_, Cow<'de, str>> {
846+
type DeserializeContext<'a>
847+
= &'a Deserializer<'a>
848+
where
849+
Self: 'a;
850+
851+
fn into_bytes(self) -> Cow<'de, [u8]> {
852+
match self.data {
853+
Cow::Borrowed(s) => Cow::Borrowed(s.as_bytes()),
854+
Cow::Owned(s) => Cow::Owned(s.into_bytes()),
855+
}
856+
}
857+
858+
fn as_bytes(&self) -> &[u8] {
859+
self.data.as_bytes()
860+
}
861+
862+
fn into_string(self) -> Cow<'de, str> {
863+
self.data
864+
}
865+
866+
fn as_str(&self) -> &str {
867+
self.data.as_ref()
868+
}
869+
870+
fn context(&self) -> Self::DeserializeContext<'_> {
871+
self.deserializer
872+
}
873+
}
874+
841875
impl<'de> XmlCData<'de> for DataWithD<'_, BytesCData<'de>> {
842876
type DeserializeContext<'a>
843877
= &'a Deserializer<'a>
@@ -1045,6 +1079,9 @@ impl<'r> xmlity::Deserializer<'r> for &mut Deserializer<'r> {
10451079
Event::PI(bytes_pi) => visitor.visit_pi(DataWithD::new(bytes_pi, self)),
10461080
Event::DocType(bytes_text) => visitor.visit_doctype(DataWithD::new(bytes_text, self)),
10471081
Event::Eof => Err(Error::custom("Unexpected EOF")),
1082+
Event::GeneralRef(bytes_ref) => {
1083+
visitor.visit_text(DataWithD::new(bytes_ref.decode()?, self))
1084+
}
10481085
}
10491086
}
10501087

0 commit comments

Comments
 (0)