diff --git a/tokio-xmpp/src/client/async_client.rs b/tokio-xmpp/src/client/async_client.rs index c2684a3c..10119bfe 100644 --- a/tokio-xmpp/src/client/async_client.rs +++ b/tokio-xmpp/src/client/async_client.rs @@ -10,8 +10,10 @@ use super::connect::client_login; use crate::connect::{AsyncReadAndWrite, ServerConnector}; use crate::error::{Error, ProtocolError}; use crate::event::Event; +use crate::starttls::ServerConfig; use crate::xmpp_codec::Packet; use crate::xmpp_stream::{add_stanza_id, XMPPStream}; +use crate::AsyncConfig; /// XMPP client connection and state /// @@ -44,6 +46,22 @@ enum ClientState { Connected(XMPPStream), } +impl Client { + /// Start a new XMPP client using StartTLS transport + /// + /// Start polling the returned instance so that it will connect + /// and yield events. + #[cfg(feature = "starttls")] + pub fn new, P: Into>(jid: J, password: P) -> Self { + let config = AsyncConfig { + jid: jid.into(), + password: password.into(), + server: ServerConfig::UseSrv, + }; + Self::new_with_config(config) + } +} + impl Client { /// Start a new client given that the JID is already parsed. pub fn new_with_config(config: Config) -> Self { diff --git a/tokio-xmpp/src/starttls/client.rs b/tokio-xmpp/src/starttls/client.rs index d1d79761..8063f37c 100644 --- a/tokio-xmpp/src/starttls/client.rs +++ b/tokio-xmpp/src/starttls/client.rs @@ -2,25 +2,10 @@ use std::str::FromStr; use xmpp_parsers::jid::Jid; -use crate::{AsyncClient, AsyncConfig, Error, SimpleClient}; +use crate::{Error, SimpleClient}; use super::ServerConfig; -impl AsyncClient { - /// Start a new XMPP client - /// - /// Start polling the returned instance so that it will connect - /// and yield events. - pub fn new, P: Into>(jid: J, password: P) -> Self { - let config = AsyncConfig { - jid: jid.into(), - password: password.into(), - server: ServerConfig::UseSrv, - }; - Self::new_with_config(config) - } -} - impl SimpleClient { /// Start a new XMPP client and wait for a usable session pub async fn new>(jid: &str, password: P) -> Result {