From 34796c90d402a7af69f68b853927c00353af5865 Mon Sep 17 00:00:00 2001 From: xmppftw Date: Sun, 4 Aug 2024 17:32:12 +0200 Subject: [PATCH] Only expose one error type in crate root --- 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(-) diff --git a/tokio-xmpp/ChangeLog b/tokio-xmpp/ChangeLog index 924ca65e5fd9a7af71533ff25c3874ea4726b937..205f2af9731c3a99102962bfa2f842f78e4f2a4a 100644 --- a/tokio-xmpp/ChangeLog +++ b/tokio-xmpp/ChangeLog @@ -5,6 +5,8 @@ XXXX-YY-ZZ RELEASER - 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 diff --git a/tokio-xmpp/src/client/async_client.rs b/tokio-xmpp/src/client/async_client.rs index a79d8f83b47dbd2e0873a5b6e89cce8ceb17b268..c2684a3c84e9594653873afd0e7b3a271ff3b5b2 100644 --- a/tokio-xmpp/src/client/async_client.rs +++ b/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 /// diff --git a/tokio-xmpp/src/client/auth.rs b/tokio-xmpp/src/client/auth.rs index 9c7f35de0c61a4279efca00e0515d32e7f5c2158..437ec799217bab30cead21d0ce6f0856b73afaa5 100644 --- a/tokio-xmpp/src/client/auth.rs +++ b/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( mut stream: XMPPStream, diff --git a/tokio-xmpp/src/client/bind.rs b/tokio-xmpp/src/client/bind.rs index ca79ff63db8c4ed588a6fd3dfe010e7dbe9f2af7..de791a8fbacdf105d7300ff90df2859517023ccf 100644 --- a/tokio-xmpp/src/client/bind.rs +++ b/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"; diff --git a/tokio-xmpp/src/component/auth.rs b/tokio-xmpp/src/component/auth.rs index 36f2bf7d01989c79dfe00fbe59d4cbe62f135bc8..370c77a18e32d129c806df5339b4a40ac4b30663 100644 --- a/tokio-xmpp/src/component/auth.rs +++ b/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( stream: &mut XMPPStream, diff --git a/tokio-xmpp/src/lib.rs b/tokio-xmpp/src/lib.rs index 89fb249ab0203bdc91786e20206a30f054b0425e..b922cd65af0e41e9aff002f4e0bd082d50224332 100644 --- a/tokio-xmpp/src/lib.rs +++ b/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; diff --git a/tokio-xmpp/src/starttls/mod.rs b/tokio-xmpp/src/starttls/mod.rs index 92d952c4a2440482bd5d994401036328842258d7..277d0905507043d0f3445b38cfa03e076dd179aa 100644 --- a/tokio-xmpp/src/starttls/mod.rs +++ b/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( 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()); } } } diff --git a/tokio-xmpp/src/stream_start.rs b/tokio-xmpp/src/stream_start.rs index effaf20d174a3e51a910bd51482d7f13b40ec703..f8a90338175eae6e5ae38b5866f18369997f9dbd 100644 --- a/tokio-xmpp/src/stream_start.rs +++ b/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 ``, then wait for one from the server, and /// construct an XMPPStream.