Bump rxml to 0.14.0

This commit is contained in:
Jonas Schäfer 2025-09-28 09:40:44 +02:00
commit bb02836097
10 changed files with 53 additions and 32 deletions

View file

@ -21,8 +21,8 @@ edition = "2021"
gitlab = { repository = "xmpp-rs/xmpp-rs" }
[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"
[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" ] }

View file

@ -119,7 +119,7 @@ pub fn escape(raw: &[u8]) -> Cow<'_, [u8]> {
/// A struct representing a DOM Element.
pub struct Element {
name: String,
namespace: String,
namespace: RxmlNamespace<'static>,
/// Namespace declarations
pub prefixes: Prefixes,
attributes: AttrMap,
@ -168,7 +168,7 @@ impl Element {
) -> Element {
Element {
name,
namespace,
namespace: namespace.into(),
prefixes: prefixes.into(),
attributes,
children,
@ -240,7 +240,7 @@ impl Element {
/// Returns a reference to the namespace of this element.
#[must_use]
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`.
@ -259,11 +259,11 @@ impl Element {
#[must_use]
pub fn attr_ns<'a, NS: Ord + Hash + Eq + ?Sized, N: Ord + Hash + Eq + ?Sized>(
&'a self,
ns: &'a NS,
name: &'a N,
ns: &NS,
name: &N,
) -> Option<&'a str>
where
RxmlNamespace: Borrow<NS>,
RxmlNamespace<'static>: Borrow<NS>,
NcName: Borrow<N>,
{
if let Some(value) = self.attributes.get(ns, name) {
@ -300,7 +300,12 @@ impl Element {
}
/// 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();
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(&namespace, (*self.name).try_into()?))?;
writer.write(Item::ElementHeadStart(
self.namespace.clone(),
(*self.name).try_into()?,
))?;
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() {
@ -908,7 +915,7 @@ impl ElementBuilder {
#[must_use]
pub fn attr_ns<V: IntoAttributeValue>(
mut self,
ns: RxmlNamespace,
ns: RxmlNamespace<'static>,
name: NcName,
value: V,
) -> ElementBuilder {

View file

@ -399,8 +399,8 @@ mod tests {
#[test]
fn test_size() {
assert_size!(IqHeader, 88);
assert_size!(IqPayload, 216);
assert_size!(Iq, 424);
assert_size!(IqPayload, 208);
assert_size!(Iq, 408);
}
#[test]

View file

@ -59,7 +59,7 @@ mod tests {
#[cfg(target_pointer_width = "64")]
#[test]
fn test_size() {
assert_size!(JingleMI, 144);
assert_size!(JingleMI, 136);
}
#[test]

View file

@ -303,7 +303,7 @@ mod tests {
fn test_size() {
assert_size!(ErrorType, 1);
assert_size!(DefinedCondition, 32);
assert_size!(StanzaError, 216);
assert_size!(StanzaError, 208);
}
#[test]

View file

@ -19,7 +19,7 @@ tokio = { version = "1", features = ["net", "rt", "rt-multi-thread", "macros", "
tokio-stream = { version = "0.1", features = ["sync"] }
webpki-roots = { version = "1", 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"
syntect = { version = "5", optional = true }
pin-project-lite = { version = "0.2" }

View file

@ -20,7 +20,7 @@ proc-macro = true
quote = "1"
syn = { version = "2", features = ["full", "extra-traits"] }
proc-macro2 = "1"
rxml_validation = { version = "0.11", default-features = false, features = ["std"] }
rxml_validation = { version = "0.12", default-features = false, features = ["std"] }
[features]
panicking-into-impl = ["minidom"]

View file

@ -32,7 +32,17 @@ pub(crate) fn namespace_ty(span: Span) -> Type {
},
PathSegment {
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()

View file

@ -11,7 +11,7 @@ license = "MPL-2.0"
[dependencies]
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" }
xso_proc = { version = "0.2", path = "../xso-proc", optional = true }

View file

@ -6,7 +6,7 @@
//! 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};
@ -27,7 +27,7 @@ pub enum Item<'x> {
/// Start of an element header
ElementHeadStart(
/// Namespace name
Namespace,
Namespace<'x>,
/// Local name of the attribute
Cow<'x, NcNameStr>,
),
@ -35,7 +35,7 @@ pub enum Item<'x> {
/// An attribute key/value pair
Attribute(
/// Namespace name
Namespace,
Namespace<'x>,
/// Local name of the attribute
Cow<'x, NcNameStr>,
/// Value of the attribute
@ -67,10 +67,10 @@ impl Item<'_> {
match self {
Self::XmlDeclaration(v) => Item::XmlDeclaration(v),
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(
ns,
ns.into_static(),
Cow::Owned(name.into_owned()),
Cow::Owned(value.into_owned()),
),
@ -84,8 +84,12 @@ impl Item<'_> {
pub fn as_rxml_item(&self) -> rxml::Item<'_> {
match self {
Self::XmlDeclaration(ref v) => rxml::Item::XmlDeclaration(*v),
Self::ElementHeadStart(ref ns, ref name) => rxml::Item::ElementHeadStart(ns, name),
Self::Attribute(ref ns, ref name, ref value) => rxml::Item::Attribute(ns, name, value),
Self::ElementHeadStart(ref ns, ref name) => {
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::Text(ref value) => rxml::Item::Text(value),
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> {
inner: I,
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> {
@ -201,7 +205,7 @@ impl<I> ItemToEvent<I> {
// runtime error.
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)
}
Item::Attribute(ns, name, value) => {
@ -214,7 +218,7 @@ impl<I> ItemToEvent<I> {
ns, name
);
};
attrs.insert(ns, name.into_owned(), value.into_owned());
attrs.insert(ns.into_static(), name.into_owned(), value.into_owned());
Ok(None)
}
Item::ElementHeadEnd => {
@ -287,7 +291,7 @@ impl<'x, I: Iterator<Item = Result<Item<'x>, crate::error::Error>>> Iterator for
mod tests_minidom {
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>> {
let iter = EventToItem {