Only expose one error type in crate root

xmppftw created

Change summary

tokio-xmpp/ChangeLog                  | 2 ++
tokio-xmpp/src/client/async_client.rs | 2 +-
tokio-xmpp/src/client/auth.rs         | 2 +-
tokio-xmpp/src/client/bind.rs         | 2 +-
tokio-xmpp/src/component/auth.rs      | 2 +-
tokio-xmpp/src/lib.rs                 | 6 ++++--
tokio-xmpp/src/starttls/mod.rs        | 5 +++--
tokio-xmpp/src/stream_start.rs        | 2 +-
8 files changed, 14 insertions(+), 9 deletions(-)

Detailed changes

tokio-xmpp/ChangeLog 🔗

@@ -5,6 +5,8 @@ XXXX-YY-ZZ RELEASER <admin@example.com>
       - Removed StreamFeatures from this crate, replaced with xmpp_parsers::stream_features::StreamFeatures (!400)
       - `starttls::error::ConnectorError` variants have been merged with `starttls::error::Error`, except `ConnectorError::AllFailed`
         which was not used and has been completely removed (!418)
+      - `ProtocolError` and `AuthError` are no longer exported in crate root;
+        access them from `error` module (!423)
 
 Version 4.0.0:
 2024-07-26 Maxime “pep” Buquet <pep@bouah.net>

tokio-xmpp/src/client/async_client.rs 🔗

@@ -8,10 +8,10 @@ use xmpp_parsers::{jid::Jid, ns, stream_features::StreamFeatures};
 
 use super::connect::client_login;
 use crate::connect::{AsyncReadAndWrite, ServerConnector};
+use crate::error::{Error, ProtocolError};
 use crate::event::Event;
 use crate::xmpp_codec::Packet;
 use crate::xmpp_stream::{add_stanza_id, XMPPStream};
-use crate::{Error, ProtocolError};
 
 /// XMPP client connection and state
 ///

tokio-xmpp/src/client/auth.rs 🔗

@@ -8,9 +8,9 @@ use std::str::FromStr;
 use tokio::io::{AsyncRead, AsyncWrite};
 use xmpp_parsers::sasl::{Auth, Challenge, Failure, Mechanism as XMPPMechanism, Response, Success};
 
+use crate::error::{AuthError, Error, ProtocolError};
 use crate::xmpp_codec::Packet;
 use crate::xmpp_stream::XMPPStream;
-use crate::{AuthError, Error, ProtocolError};
 
 pub async fn auth<S: AsyncRead + AsyncWrite + Unpin>(
     mut stream: XMPPStream<S>,

tokio-xmpp/src/client/bind.rs 🔗

@@ -3,9 +3,9 @@ use tokio::io::{AsyncRead, AsyncWrite};
 use xmpp_parsers::bind::{BindQuery, BindResponse};
 use xmpp_parsers::iq::{Iq, IqType};
 
+use crate::error::{Error, ProtocolError};
 use crate::xmpp_codec::Packet;
 use crate::xmpp_stream::XMPPStream;
-use crate::{Error, ProtocolError};
 
 const BIND_REQ_ID: &str = "resource-bind";
 

tokio-xmpp/src/component/auth.rs 🔗

@@ -2,9 +2,9 @@ use futures::stream::StreamExt;
 use tokio::io::{AsyncRead, AsyncWrite};
 use xmpp_parsers::{component::Handshake, ns};
 
+use crate::error::{AuthError, Error};
 use crate::xmpp_codec::Packet;
 use crate::xmpp_stream::XMPPStream;
-use crate::{AuthError, Error};
 
 pub async fn auth<S: AsyncRead + AsyncWrite + Unpin>(
     stream: &mut XMPPStream<S>,

tokio-xmpp/src/lib.rs 🔗

@@ -38,8 +38,10 @@ pub use client::{
 };
 mod component;
 pub use crate::component::Component;
-mod error;
-pub use crate::error::{AuthError, Error, ProtocolError};
+/// Detailed error types
+pub mod error;
+/// Generic tokio_xmpp Error
+pub use crate::error::Error;
 
 // Re-exports
 pub use minidom;

tokio-xmpp/src/starttls/mod.rs 🔗

@@ -27,6 +27,7 @@ use tokio::{
 };
 use xmpp_parsers::{jid::Jid, ns};
 
+use crate::error::ProtocolError;
 use crate::{connect::ServerConnector, xmpp_codec::Packet, AsyncClient, SimpleClient};
 use crate::{connect::ServerConnectorError, xmpp_stream::XMPPStream};
 
@@ -80,7 +81,7 @@ impl ServerConnector for ServerConfig {
             // Encrypted XMPPStream
             Ok(XMPPStream::start(tls_stream, jid.clone(), ns.to_owned()).await?)
         } else {
-            return Err(crate::Error::Protocol(crate::ProtocolError::NoTls).into());
+            return Err(crate::Error::Protocol(ProtocolError::NoTls).into());
         }
     }
 
@@ -159,7 +160,7 @@ pub async fn starttls<S: AsyncRead + AsyncWrite + Unpin>(
             Some(Ok(Packet::Text(_))) => {}
             Some(Err(e)) => return Err(e.into()),
             _ => {
-                return Err(crate::Error::Protocol(crate::ProtocolError::NoTls).into());
+                return Err(crate::Error::Protocol(ProtocolError::NoTls).into());
             }
         }
     }

tokio-xmpp/src/stream_start.rs 🔗

@@ -3,9 +3,9 @@ use tokio::io::{AsyncRead, AsyncWrite};
 use tokio_util::codec::Framed;
 use xmpp_parsers::{jid::Jid, ns, stream_features::StreamFeatures};
 
+use crate::error::{Error, ProtocolError};
 use crate::xmpp_codec::{Packet, XmppCodec};
 use crate::xmpp_stream::XMPPStream;
-use crate::{Error, ProtocolError};
 
 /// Sends a `<stream:stream>`, then wait for one from the server, and
 /// construct an XMPPStream.