DNS/TLS deps are now optional, component now also uses ServerConnector

This commit is contained in:
moparisthebest 2023-12-30 22:08:37 -05:00
commit 733d005f51
No known key found for this signature in database
GPG key ID: 88C93BFE27BC8229
17 changed files with 440 additions and 337 deletions

View file

@ -0,0 +1,18 @@
use xmpp_parsers::{ns, Jid};
use crate::connect::ServerConnector;
use crate::{xmpp_stream::XMPPStream, Error};
use super::auth::auth;
/// Log into an XMPP server as a client with a jid+pass
pub async fn component_login<C: ServerConnector>(
connector: C,
jid: Jid,
password: String,
) -> Result<XMPPStream<C::Stream>, Error> {
let password = password;
let mut xmpp_stream = connector.connect(&jid, ns::COMPONENT).await?;
auth(&mut xmpp_stream, password).await?;
Ok(xmpp_stream)
}