From 06b97ea22849162c2e9e798f0d02ae578f7469f1 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 2 Aug 2018 00:00:00 +0200 Subject: [PATCH] ClientBind: replace with xmpp_parsers::bind::Bind --- src/client/bind.rs | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/client/bind.rs b/src/client/bind.rs index 1541afd3..d258f7b7 100644 --- a/src/client/bind.rs +++ b/src/client/bind.rs @@ -5,6 +5,7 @@ use futures::{Future, Poll, Async, sink, Sink, Stream}; use tokio_io::{AsyncRead, AsyncWrite}; use jid::Jid; use minidom::Element; +use xmpp_parsers::bind::Bind; use xmpp_codec::Packet; use xmpp_stream::XMPPStream; @@ -30,7 +31,10 @@ impl ClientBind { // return the (probably // usable) stream immediately ClientBind::Unsupported(stream), Some(_) => { - let iq = make_bind_request(stream.jid.resource.as_ref()); + let resource = stream.jid.resource.clone(); + let iq = Element::from( + Bind::new(resource) + ); let send = stream.send(Packet::Stanza(iq)); ClientBind::WaitSend(send) }, @@ -38,21 +42,6 @@ impl ClientBind { } } -fn make_bind_request(resource: Option<&String>) -> Element { - let iq = Element::builder("iq") - .attr("type", "set") - .attr("id", BIND_REQ_ID); - let mut bind_el = Element::builder("bind") - .ns(NS_XMPP_BIND); - if let Some(resource) = resource { - let resource_el = Element::builder("resource") - .append(resource); - bind_el = bind_el.append(resource_el.build()); - } - iq.append(bind_el.build()) - .build() -} - impl Future for ClientBind { type Item = XMPPStream; type Error = String;