Bump rxml to 0.14.0
This commit is contained in:
parent
954efd2673
commit
bb02836097
10 changed files with 53 additions and 32 deletions
|
|
@ -21,8 +21,8 @@ edition = "2021"
|
||||||
gitlab = { repository = "xmpp-rs/xmpp-rs" }
|
gitlab = { repository = "xmpp-rs/xmpp-rs" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rxml = { version = "0.13.3", default-features = false, features = [ "std", "compact_str" ] }
|
rxml = { version = "0.14.0", default-features = false, features = [ "std", "compact_str" ] }
|
||||||
thiserror = "2.0"
|
thiserror = "2.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rxml = { version = "0.13.1", default-features = false, features = [ "std", "compact_str", "macros" ] }
|
rxml = { version = "0.14.0", default-features = false, features = [ "std", "compact_str", "macros" ] }
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ pub fn escape(raw: &[u8]) -> Cow<'_, [u8]> {
|
||||||
/// A struct representing a DOM Element.
|
/// A struct representing a DOM Element.
|
||||||
pub struct Element {
|
pub struct Element {
|
||||||
name: String,
|
name: String,
|
||||||
namespace: String,
|
namespace: RxmlNamespace<'static>,
|
||||||
/// Namespace declarations
|
/// Namespace declarations
|
||||||
pub prefixes: Prefixes,
|
pub prefixes: Prefixes,
|
||||||
attributes: AttrMap,
|
attributes: AttrMap,
|
||||||
|
|
@ -168,7 +168,7 @@ impl Element {
|
||||||
) -> Element {
|
) -> Element {
|
||||||
Element {
|
Element {
|
||||||
name,
|
name,
|
||||||
namespace,
|
namespace: namespace.into(),
|
||||||
prefixes: prefixes.into(),
|
prefixes: prefixes.into(),
|
||||||
attributes,
|
attributes,
|
||||||
children,
|
children,
|
||||||
|
|
@ -240,7 +240,7 @@ impl Element {
|
||||||
/// Returns a reference to the namespace of this element.
|
/// Returns a reference to the namespace of this element.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn ns(&self) -> String {
|
pub fn ns(&self) -> String {
|
||||||
self.namespace.clone()
|
self.namespace.clone().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reference to the value of the given attribute, if it exists, else `None`.
|
/// Returns a reference to the value of the given attribute, if it exists, else `None`.
|
||||||
|
|
@ -259,11 +259,11 @@ impl Element {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn attr_ns<'a, NS: Ord + Hash + Eq + ?Sized, N: Ord + Hash + Eq + ?Sized>(
|
pub fn attr_ns<'a, NS: Ord + Hash + Eq + ?Sized, N: Ord + Hash + Eq + ?Sized>(
|
||||||
&'a self,
|
&'a self,
|
||||||
ns: &'a NS,
|
ns: &NS,
|
||||||
name: &'a N,
|
name: &N,
|
||||||
) -> Option<&'a str>
|
) -> Option<&'a str>
|
||||||
where
|
where
|
||||||
RxmlNamespace: Borrow<NS>,
|
RxmlNamespace<'static>: Borrow<NS>,
|
||||||
NcName: Borrow<N>,
|
NcName: Borrow<N>,
|
||||||
{
|
{
|
||||||
if let Some(value) = self.attributes.get(ns, name) {
|
if let Some(value) = self.attributes.get(ns, name) {
|
||||||
|
|
@ -300,7 +300,12 @@ impl Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Modifies the value of an attribute.
|
/// Modifies the value of an attribute.
|
||||||
pub fn set_attr<V: IntoAttributeValue>(&mut self, ns: RxmlNamespace, name: NcName, val: V) {
|
pub fn set_attr<V: IntoAttributeValue>(
|
||||||
|
&mut self,
|
||||||
|
ns: RxmlNamespace<'static>,
|
||||||
|
name: NcName,
|
||||||
|
val: V,
|
||||||
|
) {
|
||||||
let val = val.into_attribute_value();
|
let val = val.into_attribute_value();
|
||||||
|
|
||||||
if let Some(value) = self.attributes.get_mut(&ns, &name) {
|
if let Some(value) = self.attributes.get_mut(&ns, &name) {
|
||||||
|
|
@ -421,11 +426,13 @@ impl Element {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let namespace: RxmlNamespace = self.namespace.clone().into();
|
writer.write(Item::ElementHeadStart(
|
||||||
writer.write(Item::ElementHeadStart(&namespace, (*self.name).try_into()?))?;
|
self.namespace.clone(),
|
||||||
|
(*self.name).try_into()?,
|
||||||
|
))?;
|
||||||
|
|
||||||
for ((ns, key), value) in &self.attributes {
|
for ((ns, key), value) in &self.attributes {
|
||||||
writer.write(Item::Attribute(ns, key, value))?;
|
writer.write(Item::Attribute(ns.clone(), key, value))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.children.is_empty() {
|
if !self.children.is_empty() {
|
||||||
|
|
@ -908,7 +915,7 @@ impl ElementBuilder {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn attr_ns<V: IntoAttributeValue>(
|
pub fn attr_ns<V: IntoAttributeValue>(
|
||||||
mut self,
|
mut self,
|
||||||
ns: RxmlNamespace,
|
ns: RxmlNamespace<'static>,
|
||||||
name: NcName,
|
name: NcName,
|
||||||
value: V,
|
value: V,
|
||||||
) -> ElementBuilder {
|
) -> ElementBuilder {
|
||||||
|
|
|
||||||
|
|
@ -399,8 +399,8 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
assert_size!(IqHeader, 88);
|
assert_size!(IqHeader, 88);
|
||||||
assert_size!(IqPayload, 216);
|
assert_size!(IqPayload, 208);
|
||||||
assert_size!(Iq, 424);
|
assert_size!(Iq, 408);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ mod tests {
|
||||||
#[cfg(target_pointer_width = "64")]
|
#[cfg(target_pointer_width = "64")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
assert_size!(JingleMI, 144);
|
assert_size!(JingleMI, 136);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ mod tests {
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
assert_size!(ErrorType, 1);
|
assert_size!(ErrorType, 1);
|
||||||
assert_size!(DefinedCondition, 32);
|
assert_size!(DefinedCondition, 32);
|
||||||
assert_size!(StanzaError, 216);
|
assert_size!(StanzaError, 208);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ tokio = { version = "1", features = ["net", "rt", "rt-multi-thread", "macros", "
|
||||||
tokio-stream = { version = "0.1", features = ["sync"] }
|
tokio-stream = { version = "0.1", features = ["sync"] }
|
||||||
webpki-roots = { version = "1", optional = true }
|
webpki-roots = { version = "1", optional = true }
|
||||||
rustls-native-certs = { version = "0.8", optional = true }
|
rustls-native-certs = { version = "0.8", optional = true }
|
||||||
rxml = { version = "0.13.1", features = ["compact_str"] }
|
rxml = { version = "0.14.0", features = ["compact_str", "tokio"] }
|
||||||
rand = "0.9"
|
rand = "0.9"
|
||||||
syntect = { version = "5", optional = true }
|
syntect = { version = "5", optional = true }
|
||||||
pin-project-lite = { version = "0.2" }
|
pin-project-lite = { version = "0.2" }
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ proc-macro = true
|
||||||
quote = "1"
|
quote = "1"
|
||||||
syn = { version = "2", features = ["full", "extra-traits"] }
|
syn = { version = "2", features = ["full", "extra-traits"] }
|
||||||
proc-macro2 = "1"
|
proc-macro2 = "1"
|
||||||
rxml_validation = { version = "0.11", default-features = false, features = ["std"] }
|
rxml_validation = { version = "0.12", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
panicking-into-impl = ["minidom"]
|
panicking-into-impl = ["minidom"]
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,17 @@ pub(crate) fn namespace_ty(span: Span) -> Type {
|
||||||
},
|
},
|
||||||
PathSegment {
|
PathSegment {
|
||||||
ident: Ident::new("Namespace", span),
|
ident: Ident::new("Namespace", span),
|
||||||
arguments: PathArguments::None,
|
arguments: PathArguments::AngleBracketed(AngleBracketedGenericArguments {
|
||||||
|
colon2_token: None,
|
||||||
|
lt_token: token::Lt { spans: [span] },
|
||||||
|
args: [GenericArgument::Lifetime(Lifetime {
|
||||||
|
apostrophe: Span::call_site(),
|
||||||
|
ident: Ident::new("static", Span::call_site()),
|
||||||
|
})]
|
||||||
|
.into_iter()
|
||||||
|
.collect(),
|
||||||
|
gt_token: token::Gt { spans: [span] },
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ license = "MPL-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bytes = { version = "1" }
|
bytes = { version = "1" }
|
||||||
rxml = { version = "0.13.1", default-features = false }
|
rxml = { version = "0.14.0", default-features = false }
|
||||||
minidom = { version = "0.18", path = "../minidom" }
|
minidom = { version = "0.18", path = "../minidom" }
|
||||||
xso_proc = { version = "0.2", path = "../xso-proc", optional = true }
|
xso_proc = { version = "0.2", path = "../xso-proc", optional = true }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
//! Utilities which may eventually move upstream to the `rxml` crate.
|
//! Utilities which may eventually move upstream to the `rxml` crate.
|
||||||
|
|
||||||
use alloc::borrow::{Cow, ToOwned};
|
use alloc::borrow::Cow;
|
||||||
|
|
||||||
use rxml::{parser::EventMetrics, AttrMap, Event, Namespace, NcName, NcNameStr, XmlVersion};
|
use rxml::{parser::EventMetrics, AttrMap, Event, Namespace, NcName, NcNameStr, XmlVersion};
|
||||||
|
|
||||||
|
|
@ -27,7 +27,7 @@ pub enum Item<'x> {
|
||||||
/// Start of an element header
|
/// Start of an element header
|
||||||
ElementHeadStart(
|
ElementHeadStart(
|
||||||
/// Namespace name
|
/// Namespace name
|
||||||
Namespace,
|
Namespace<'x>,
|
||||||
/// Local name of the attribute
|
/// Local name of the attribute
|
||||||
Cow<'x, NcNameStr>,
|
Cow<'x, NcNameStr>,
|
||||||
),
|
),
|
||||||
|
|
@ -35,7 +35,7 @@ pub enum Item<'x> {
|
||||||
/// An attribute key/value pair
|
/// An attribute key/value pair
|
||||||
Attribute(
|
Attribute(
|
||||||
/// Namespace name
|
/// Namespace name
|
||||||
Namespace,
|
Namespace<'x>,
|
||||||
/// Local name of the attribute
|
/// Local name of the attribute
|
||||||
Cow<'x, NcNameStr>,
|
Cow<'x, NcNameStr>,
|
||||||
/// Value of the attribute
|
/// Value of the attribute
|
||||||
|
|
@ -67,10 +67,10 @@ impl Item<'_> {
|
||||||
match self {
|
match self {
|
||||||
Self::XmlDeclaration(v) => Item::XmlDeclaration(v),
|
Self::XmlDeclaration(v) => Item::XmlDeclaration(v),
|
||||||
Self::ElementHeadStart(ns, name) => {
|
Self::ElementHeadStart(ns, name) => {
|
||||||
Item::ElementHeadStart(ns, Cow::Owned(name.into_owned()))
|
Item::ElementHeadStart(ns.into_static(), Cow::Owned(name.into_owned()))
|
||||||
}
|
}
|
||||||
Self::Attribute(ns, name, value) => Item::Attribute(
|
Self::Attribute(ns, name, value) => Item::Attribute(
|
||||||
ns,
|
ns.into_static(),
|
||||||
Cow::Owned(name.into_owned()),
|
Cow::Owned(name.into_owned()),
|
||||||
Cow::Owned(value.into_owned()),
|
Cow::Owned(value.into_owned()),
|
||||||
),
|
),
|
||||||
|
|
@ -84,8 +84,12 @@ impl Item<'_> {
|
||||||
pub fn as_rxml_item(&self) -> rxml::Item<'_> {
|
pub fn as_rxml_item(&self) -> rxml::Item<'_> {
|
||||||
match self {
|
match self {
|
||||||
Self::XmlDeclaration(ref v) => rxml::Item::XmlDeclaration(*v),
|
Self::XmlDeclaration(ref v) => rxml::Item::XmlDeclaration(*v),
|
||||||
Self::ElementHeadStart(ref ns, ref name) => rxml::Item::ElementHeadStart(ns, name),
|
Self::ElementHeadStart(ref ns, ref name) => {
|
||||||
Self::Attribute(ref ns, ref name, ref value) => rxml::Item::Attribute(ns, name, value),
|
rxml::Item::ElementHeadStart(ns.clone(), name)
|
||||||
|
}
|
||||||
|
Self::Attribute(ref ns, ref name, ref value) => {
|
||||||
|
rxml::Item::Attribute(ns.clone(), name, value)
|
||||||
|
}
|
||||||
Self::ElementHeadEnd => rxml::Item::ElementHeadEnd,
|
Self::ElementHeadEnd => rxml::Item::ElementHeadEnd,
|
||||||
Self::Text(ref value) => rxml::Item::Text(value),
|
Self::Text(ref value) => rxml::Item::Text(value),
|
||||||
Self::ElementFoot => rxml::Item::ElementFoot,
|
Self::ElementFoot => rxml::Item::ElementFoot,
|
||||||
|
|
@ -172,7 +176,7 @@ impl<I: Iterator<Item = Result<Event, crate::error::Error>>> Iterator for EventT
|
||||||
pub(crate) struct ItemToEvent<I> {
|
pub(crate) struct ItemToEvent<I> {
|
||||||
inner: I,
|
inner: I,
|
||||||
event_buffer: Option<Event>,
|
event_buffer: Option<Event>,
|
||||||
elem_buffer: Option<(Namespace, NcName, AttrMap)>,
|
elem_buffer: Option<(Namespace<'static>, NcName, AttrMap)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'x, I: Iterator<Item = Result<Item<'x>, crate::error::Error>>> ItemToEvent<I> {
|
impl<'x, I: Iterator<Item = Result<Item<'x>, crate::error::Error>>> ItemToEvent<I> {
|
||||||
|
|
@ -201,7 +205,7 @@ impl<I> ItemToEvent<I> {
|
||||||
// runtime error.
|
// runtime error.
|
||||||
panic!("got a second ElementHeadStart items without ElementHeadEnd inbetween: ns={:?} name={:?} (state={:?})", ns, name, self.elem_buffer);
|
panic!("got a second ElementHeadStart items without ElementHeadEnd inbetween: ns={:?} name={:?} (state={:?})", ns, name, self.elem_buffer);
|
||||||
}
|
}
|
||||||
self.elem_buffer = Some((ns.to_owned(), name.into_owned(), AttrMap::new()));
|
self.elem_buffer = Some((ns.into_static(), name.into_owned(), AttrMap::new()));
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
Item::Attribute(ns, name, value) => {
|
Item::Attribute(ns, name, value) => {
|
||||||
|
|
@ -214,7 +218,7 @@ impl<I> ItemToEvent<I> {
|
||||||
ns, name
|
ns, name
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
attrs.insert(ns, name.into_owned(), value.into_owned());
|
attrs.insert(ns.into_static(), name.into_owned(), value.into_owned());
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
Item::ElementHeadEnd => {
|
Item::ElementHeadEnd => {
|
||||||
|
|
@ -287,7 +291,7 @@ impl<'x, I: Iterator<Item = Result<Item<'x>, crate::error::Error>>> Iterator for
|
||||||
mod tests_minidom {
|
mod tests_minidom {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use alloc::{string::ToString, vec, vec::Vec};
|
use alloc::{borrow::ToOwned, string::ToString, vec, vec::Vec};
|
||||||
|
|
||||||
fn events_to_items<I: Iterator<Item = Event>>(events: I) -> Vec<Item<'static>> {
|
fn events_to_items<I: Iterator<Item = Event>>(events: I) -> Vec<Item<'static>> {
|
||||||
let iter = EventToItem {
|
let iter = EventToItem {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue