From 33ee71bcb488a7a1f97bb96a2530a59b32643725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sat, 4 Apr 2020 23:40:30 +0200 Subject: [PATCH] tokio-xmpp: update for minidom changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- tokio-xmpp/src/starttls.rs | 2 +- tokio-xmpp/src/stream_start.rs | 2 +- tokio-xmpp/src/xmpp_codec.rs | 21 ++++++++++++--------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tokio-xmpp/src/starttls.rs b/tokio-xmpp/src/starttls.rs index 49c52cb9..28923c47 100644 --- a/tokio-xmpp/src/starttls.rs +++ b/tokio-xmpp/src/starttls.rs @@ -16,7 +16,7 @@ pub const NS_XMPP_TLS: &str = "urn:ietf:params:xml:ns:xmpp-tls"; pub async fn starttls( mut xmpp_stream: XMPPStream, ) -> Result, Error> { - let nonza = Element::builder("starttls").ns(NS_XMPP_TLS).build(); + let nonza = Element::builder("starttls", NS_XMPP_TLS).build(); let packet = Packet::Stanza(nonza); xmpp_stream.send(packet).await?; diff --git a/tokio-xmpp/src/stream_start.rs b/tokio-xmpp/src/stream_start.rs index 0dabbd6e..b9e898ae 100644 --- a/tokio-xmpp/src/stream_start.rs +++ b/tokio-xmpp/src/stream_start.rs @@ -70,7 +70,7 @@ pub async fn start( stream, ns, stream_id.clone(), - Element::builder(stream_id).build(), + Element::builder(stream_id, NS_XMPP_STREAM).build(), ) }; Ok(stream) diff --git a/tokio-xmpp/src/xmpp_codec.rs b/tokio-xmpp/src/xmpp_codec.rs index eaf927d3..cb956b3f 100644 --- a/tokio-xmpp/src/xmpp_codec.rs +++ b/tokio-xmpp/src/xmpp_codec.rs @@ -95,12 +95,10 @@ impl ParserSink { self.ns_stack.push(nss); let el = { - let mut el_builder = Element::builder(tag.name.local.as_ref()); - if let Some(el_ns) = - self.lookup_ns(&tag.name.prefix.map(|prefix| prefix.as_ref().to_owned())) - { - el_builder = el_builder.ns(el_ns); - } + let el_ns = self + .lookup_ns(&tag.name.prefix.map(|prefix| prefix.as_ref().to_owned())) + .unwrap(); + let mut el_builder = Element::builder(tag.name.local.as_ref(), el_ns); for attr in &tag.attrs { match attr.name.local.as_ref() { "xmlns" => (), @@ -490,13 +488,18 @@ mod tests { for _ in 0..2usize.pow(15) { text = text + "A"; } - let stanza = Element::builder("message") - .append(Element::builder("body").append(text.as_ref()).build()) + let stanza = Element::builder("message", "jabber:client") + .append( + Element::builder("body", "jabber:client") + .append(text.as_ref()) + .build(), + ) .build(); block_on(framed.send(Packet::Stanza(stanza))).expect("send"); assert_eq!( framed.get_ref().get_ref(), - &("".to_owned() + &text + "").as_bytes() + &("".to_owned() + &text + "") + .as_bytes() ); }