From bb028360976449285bc45dfd57e7991729a2959e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Sun, 28 Sep 2025 09:40:44 +0200 Subject: [PATCH] Bump rxml to 0.14.0 --- minidom/Cargo.toml | 4 ++-- minidom/src/element.rs | 29 ++++++++++++++++++----------- parsers/src/iq.rs | 4 ++-- parsers/src/jingle_message.rs | 2 +- parsers/src/stanza_error.rs | 2 +- tokio-xmpp/Cargo.toml | 2 +- xso-proc/Cargo.toml | 2 +- xso-proc/src/types.rs | 12 +++++++++++- xso/Cargo.toml | 2 +- xso/src/rxml_util.rs | 26 +++++++++++++++----------- 10 files changed, 53 insertions(+), 32 deletions(-) diff --git a/minidom/Cargo.toml b/minidom/Cargo.toml index 7d9838a4..d953f170 100644 --- a/minidom/Cargo.toml +++ b/minidom/Cargo.toml @@ -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" ] } diff --git a/minidom/src/element.rs b/minidom/src/element.rs index 130d6b24..f861de4f 100644 --- a/minidom/src/element.rs +++ b/minidom/src/element.rs @@ -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, + RxmlNamespace<'static>: Borrow, NcName: Borrow, { 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(&mut self, ns: RxmlNamespace, name: NcName, val: V) { + pub fn set_attr( + &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( mut self, - ns: RxmlNamespace, + ns: RxmlNamespace<'static>, name: NcName, value: V, ) -> ElementBuilder { diff --git a/parsers/src/iq.rs b/parsers/src/iq.rs index 5a528623..1c465308 100644 --- a/parsers/src/iq.rs +++ b/parsers/src/iq.rs @@ -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] diff --git a/parsers/src/jingle_message.rs b/parsers/src/jingle_message.rs index 2a3f7440..90599ef6 100644 --- a/parsers/src/jingle_message.rs +++ b/parsers/src/jingle_message.rs @@ -59,7 +59,7 @@ mod tests { #[cfg(target_pointer_width = "64")] #[test] fn test_size() { - assert_size!(JingleMI, 144); + assert_size!(JingleMI, 136); } #[test] diff --git a/parsers/src/stanza_error.rs b/parsers/src/stanza_error.rs index 567e80a5..6c72af28 100644 --- a/parsers/src/stanza_error.rs +++ b/parsers/src/stanza_error.rs @@ -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] diff --git a/tokio-xmpp/Cargo.toml b/tokio-xmpp/Cargo.toml index b7222fce..3aa6f589 100644 --- a/tokio-xmpp/Cargo.toml +++ b/tokio-xmpp/Cargo.toml @@ -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" } diff --git a/xso-proc/Cargo.toml b/xso-proc/Cargo.toml index 5876167b..41dc87e7 100644 --- a/xso-proc/Cargo.toml +++ b/xso-proc/Cargo.toml @@ -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"] diff --git a/xso-proc/src/types.rs b/xso-proc/src/types.rs index 9ee85823..d71f717a 100644 --- a/xso-proc/src/types.rs +++ b/xso-proc/src/types.rs @@ -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() diff --git a/xso/Cargo.toml b/xso/Cargo.toml index 247c95fc..1b629973 100644 --- a/xso/Cargo.toml +++ b/xso/Cargo.toml @@ -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 } diff --git a/xso/src/rxml_util.rs b/xso/src/rxml_util.rs index 61a4ddd4..ec6e09ec 100644 --- a/xso/src/rxml_util.rs +++ b/xso/src/rxml_util.rs @@ -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>> Iterator for EventT pub(crate) struct ItemToEvent { inner: I, event_buffer: Option, - elem_buffer: Option<(Namespace, NcName, AttrMap)>, + elem_buffer: Option<(Namespace<'static>, NcName, AttrMap)>, } impl<'x, I: Iterator, crate::error::Error>>> ItemToEvent { @@ -201,7 +205,7 @@ impl ItemToEvent { // 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 ItemToEvent { 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, 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>(events: I) -> Vec> { let iter = EventToItem {