Detailed changes
@@ -3,7 +3,7 @@ use minidom::Element;
use std::env::args;
use std::process::exit;
use std::str::FromStr;
-use tokio_xmpp::tcp::TcpComponent as Component;
+use tokio_xmpp::connect::tcp::TcpComponent as Component;
use xmpp_parsers::jid::Jid;
use xmpp_parsers::message::{Body, Message, MessageType};
use xmpp_parsers::presence::{Presence, Show as PresenceShow, Type as PresenceType};
@@ -17,6 +17,9 @@ use xmpp_parsers::jid::Jid;
use crate::xmpp_stream::XMPPStream;
use crate::Error;
+#[cfg(feature="insecure-tcp")]
+pub mod tcp;
+
/// trait returned wrapped in XMPPStream by ServerConnector
pub trait AsyncReadAndWrite: AsyncRead + AsyncWrite + Unpin + Send {}
impl<T: AsyncRead + AsyncWrite + Unpin + Send> AsyncReadAndWrite for T {}
@@ -4,12 +4,7 @@ use std::sync::Arc;
use tokio::net::TcpStream;
-use crate::{connect::ServerConnector, xmpp_stream::XMPPStream, Component};
-
-use crate::Error;
-
-mod component;
-pub mod error;
+use crate::{connect::ServerConnector, xmpp_stream::XMPPStream, Component, Error};
/// Component that connects over TCP
pub type TcpComponent = Component<TcpServerConnector>;
@@ -40,3 +35,11 @@ impl ServerConnector for TcpServerConnector {
Ok(XMPPStream::start(stream, jid.clone(), ns.to_owned()).await?)
}
}
+
+impl Component<TcpServerConnector> {
+ /// Start a new XMPP component
+ pub async fn new(jid: &str, password: &str, server: String) -> Result<Self, Error> {
+ Self::new_with_connector(jid, password, TcpServerConnector::new(server)).await
+ }
+}
+
@@ -23,8 +23,6 @@ compile_error!(
#[cfg(feature = "starttls")]
pub mod starttls;
mod stream_start;
-#[cfg(feature = "insecure-tcp")]
-pub mod tcp;
mod xmpp_codec;
pub use crate::xmpp_codec::{Packet, XmppCodec};
mod event;
@@ -1,10 +0,0 @@
-use crate::{Component, Error};
-
-use super::TcpServerConnector;
-
-impl Component<TcpServerConnector> {
- /// Start a new XMPP component
- pub async fn new(jid: &str, password: &str, server: String) -> Result<Self, Error> {
- Self::new_with_connector(jid, password, TcpServerConnector::new(server)).await
- }
-}
@@ -1,26 +0,0 @@
-//! TCP ServerConnector Error
-
-use core::fmt;
-
-/// TCP ServerConnector Error
-#[derive(Debug)]
-pub enum Error {
- /// tokio-xmpp error
- TokioXMPP(crate::error::Error),
-}
-
-impl std::error::Error for Error {}
-
-impl fmt::Display for Error {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- match self {
- Error::TokioXMPP(e) => write!(fmt, "TokioXMPP error: {}", e),
- }
- }
-}
-
-impl From<crate::error::Error> for Error {
- fn from(e: crate::error::Error) -> Self {
- Error::TokioXMPP(e)
- }
-}