tokio-xmpp: Update to the new jid crate

This helps a bit thanks to fewer clones, but otherwise there are very
few changes.
This commit is contained in:
Emmanuel Gil Peyrot 2023-06-20 14:35:28 +02:00
commit 3c9df12606
5 changed files with 10 additions and 12 deletions

View file

@ -109,13 +109,13 @@ impl Client {
jid: Jid,
password: String,
) -> Result<XMPPStream, Error> {
let username = jid.clone().node().unwrap();
let username = jid.node().unwrap();
let password = password;
// TCP connection
let tcp_stream = match server {
ServerConfig::UseSrv => {
connect_with_srv(&jid.clone().domain(), "_xmpp-client._tcp", 5222).await?
connect_with_srv(jid.domain(), "_xmpp-client._tcp", 5222).await?
}
ServerConfig::Manual { host, port } => connect_to_host(host.as_str(), port).await?,
};

View file

@ -4,7 +4,6 @@ use std::marker::Unpin;
use tokio::io::{AsyncRead, AsyncWrite};
use xmpp_parsers::bind::{BindQuery, BindResponse};
use xmpp_parsers::iq::{Iq, IqType};
use xmpp_parsers::Jid;
use crate::xmpp_codec::Packet;
use crate::xmpp_stream::XMPPStream;
@ -16,11 +15,10 @@ pub async fn bind<S: AsyncRead + AsyncWrite + Unpin>(
mut stream: XMPPStream<S>,
) -> Result<XMPPStream<S>, Error> {
if stream.stream_features.can_bind() {
let resource = if let Jid::Full(jid) = stream.jid.clone() {
Some(jid.resource)
} else {
None
};
let resource = stream
.jid
.resource()
.and_then(|resource| Some(resource.to_owned()));
let iq = Iq::from_set(BIND_REQ_ID, BindQuery::new(resource));
stream.send_stanza(iq).await?;

View file

@ -50,7 +50,7 @@ impl Client {
}
async fn connect(jid: Jid, password: String) -> Result<XMPPStream, Error> {
let username = jid.clone().node().unwrap();
let username = jid.node().unwrap();
let password = password;
let domain = idna::domain_to_ascii(&jid.clone().domain()).map_err(|_| Error::Idna)?;