Only expose one error type in crate root

This commit is contained in:
xmppftw xmppftw 2024-08-04 17:32:12 +02:00
commit 84511b54a0
6 changed files with 40 additions and 55 deletions

View file

@ -4,13 +4,9 @@ use std::sync::Arc;
use tokio::net::TcpStream;
use crate::{
connect::{ServerConnector, ServerConnectorError},
xmpp_stream::XMPPStream,
Component,
};
use crate::{connect::ServerConnector, xmpp_stream::XMPPStream, Component};
use self::error::Error;
use crate::Error;
mod component;
pub mod error;
@ -31,16 +27,13 @@ impl TcpServerConnector {
}
}
impl ServerConnectorError for Error {}
impl ServerConnector for TcpServerConnector {
type Stream = TcpStream;
type Error = Error;
async fn connect(
&self,
jid: &xmpp_parsers::jid::Jid,
ns: &str,
) -> Result<XMPPStream<Self::Stream>, Self::Error> {
) -> Result<XMPPStream<Self::Stream>, Error> {
let stream = TcpStream::connect(&*self.0)
.await
.map_err(|e| crate::Error::Io(e))?;