Only expose one error type in crate root

This commit is contained in:
xmppftw xmppftw 2024-08-04 17:32:12 +02:00 • committed by Link Mauve
commit 34796c90d4
8 changed files with 14 additions and 9 deletions

View file

@ -5,6 +5,8 @@ XXXX-YY-ZZ RELEASER <admin@example.com>
- Removed StreamFeatures from this crate, replaced with xmpp_parsers::stream_features::StreamFeatures (!400) - 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` - `starttls::error::ConnectorError` variants have been merged with `starttls::error::Error`, except `ConnectorError::AllFailed`
which was not used and has been completely removed (!418) 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: Version 4.0.0:
2024-07-26 Maxime “pep” Buquet <pep@bouah.net> 2024-07-26 Maxime “pep” Buquet <pep@bouah.net>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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