JIDs now have typed and stringy methods for node/domain/resource access
Jid now has typed with_resource and stringy with_resource_str Jid now has is_full, is_bare
This commit is contained in:
parent
199b3ae7ae
commit
4266368a98
8 changed files with 177 additions and 39 deletions
|
|
@ -109,13 +109,13 @@ impl Client {
|
|||
jid: Jid,
|
||||
password: String,
|
||||
) -> Result<XMPPStream, Error> {
|
||||
let username = jid.node().unwrap();
|
||||
let username = jid.node_str().unwrap();
|
||||
let password = password;
|
||||
|
||||
// TCP connection
|
||||
let tcp_stream = match server {
|
||||
ServerConfig::UseSrv => {
|
||||
connect_with_srv(jid.domain(), "_xmpp-client._tcp", 5222).await?
|
||||
connect_with_srv(jid.domain_str(), "_xmpp-client._tcp", 5222).await?
|
||||
}
|
||||
ServerConfig::Manual { host, port } => connect_to_host(host.as_str(), port).await?,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ pub async fn bind<S: AsyncRead + AsyncWrite + Unpin>(
|
|||
if stream.stream_features.can_bind() {
|
||||
let resource = stream
|
||||
.jid
|
||||
.resource()
|
||||
.resource_str()
|
||||
.and_then(|resource| Some(resource.to_owned()));
|
||||
let iq = Iq::from_set(BIND_REQ_ID, BindQuery::new(resource));
|
||||
stream.send_stanza(iq).await?;
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ impl Client {
|
|||
}
|
||||
|
||||
async fn connect(jid: Jid, password: String) -> Result<XMPPStream, Error> {
|
||||
let username = jid.node().unwrap();
|
||||
let username = jid.node_str().unwrap();
|
||||
let password = password;
|
||||
let domain = idna::domain_to_ascii(&jid.clone().domain()).map_err(|_| Error::Idna)?;
|
||||
let domain = idna::domain_to_ascii(&jid.clone().domain_str()).map_err(|_| Error::Idna)?;
|
||||
|
||||
// TCP connection
|
||||
let tcp_stream = connect_with_srv(&domain, "_xmpp-client._tcp", 5222).await?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue