Move AsyncClient::new to client::async_client module

xmppftw created

Change summary

tokio-xmpp/src/client/async_client.rs | 18 ++++++++++++++++++
tokio-xmpp/src/starttls/client.rs     | 17 +----------------
2 files changed, 19 insertions(+), 16 deletions(-)

Detailed changes

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<S: AsyncReadAndWrite> {
     Connected(XMPPStream<S>),
 }
 
+impl Client<ServerConfig> {
+    /// 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<J: Into<Jid>, P: Into<String>>(jid: J, password: P) -> Self {
+        let config = AsyncConfig {
+            jid: jid.into(),
+            password: password.into(),
+            server: ServerConfig::UseSrv,
+        };
+        Self::new_with_config(config)
+    }
+}
+
 impl<C: ServerConnector> Client<C> {
     /// Start a new client given that the JID is already parsed.
     pub fn new_with_config(config: Config<C>) -> Self {

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<ServerConfig> {
-    /// Start a new XMPP client
-    ///
-    /// Start polling the returned instance so that it will connect
-    /// and yield events.
-    pub fn new<J: Into<Jid>, P: Into<String>>(jid: J, password: P) -> Self {
-        let config = AsyncConfig {
-            jid: jid.into(),
-            password: password.into(),
-            server: ServerConfig::UseSrv,
-        };
-        Self::new_with_config(config)
-    }
-}
-
 impl SimpleClient<ServerConfig> {
     /// Start a new XMPP client and wait for a usable session
     pub async fn new<P: Into<String>>(jid: &str, password: P) -> Result<Self, Error> {