Only expose one error type in crate root
This commit is contained in:
parent
2358c8636e
commit
34796c90d4
8 changed files with 14 additions and 9 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
///
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue