Switch to hard-xml. (#4)

strong-xml is unmaintained and this fork includes a fix to a self-closing element causing a parse error.

This also fixes a build-time warning with the strong-xml derive macro.
This commit is contained in:
Kevin Cox 2022-07-19 07:47:46 -04:00 committed by GitHub
parent 75eb03b23f
commit 34677a5fa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 28 deletions

50
Cargo.lock generated
View File

@ -86,6 +86,30 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "hard-xml"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c049a5d5186e83c3cf139192e81ab9d06c6b20d18c8aa06b38f3f6a5ece8703"
dependencies = [
"hard-xml-derive",
"jetscii",
"lazy_static",
"memchr",
"xmlparser",
]
[[package]]
name = "hard-xml-derive"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d24cec6f13bd2423158425bdb5f5ba0f2ddf7d7c2a825c0fdbf20c513df49725"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "hermit-abi"
version = "0.1.15"
@ -138,8 +162,8 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
name = "opml"
version = "1.1.3"
dependencies = [
"hard-xml",
"serde",
"strong-xml",
"thiserror",
]
@ -242,30 +266,6 @@ dependencies = [
"serde",
]
[[package]]
name = "strong-xml"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d19fb3a618e2f1039e32317c9f525e6d45c55af704ec7c429aa74412419bebf"
dependencies = [
"jetscii",
"lazy_static",
"memchr",
"strong-xml-derive",
"xmlparser",
]
[[package]]
name = "strong-xml-derive"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92c781f499321613b112be5d9338189ef1ed19689a01edd23d923ea57ad5c7e1"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "strsim"
version = "0.8.0"

View File

@ -15,7 +15,7 @@ keywords = ["xml", "opml"]
path = "source/lib.rs"
[dependencies]
strong-xml = "0.6.3"
hard-xml = "1.10.0"
thiserror = "1.0.29"
[dependencies.serde]

View File

@ -30,7 +30,7 @@
//! old `OPML { /* ... */ }` syntax.
use serde::{Deserialize, Serialize};
use strong_xml::{XmlRead, XmlWrite};
use hard_xml::{XmlRead, XmlWrite};
use thiserror::Error;
/// All possible errors.
@ -52,7 +52,7 @@ pub enum Error {
/// The input string is not valid XML.
#[error("Failed to process XML file")]
XmlError(#[from] strong_xml::XmlError),
XmlError(#[from] hard_xml::XmlError),
}
/// The top-level [`OPML`] element.

View File

@ -0,0 +1,8 @@
<opml version="2.0">
<head>
<docs />
</head>
<body>
<outline text="Outline Text"/>
</body>
</opml>

View File

@ -20,6 +20,29 @@ fn test_minimum_valid_opml() {
);
}
#[test]
fn test_valid_empty_docs() {
assert_eq!(
OPML::from_str(
&read("tests/samples/empty_docs.opml").unwrap()
)
.unwrap(),
OPML {
version: "2.0".to_string(),
head: Some(Head {
docs: Some("".to_string()),
..Head::default()
}),
body: Body {
outlines: vec![Outline {
text: "Outline Text".to_string(),
..Outline::default()
}]
},
}
)
}
#[test]
fn test_valid_opml_with_everything() {
assert_eq!(