Make Client and Component more unified, and connectors too

This commit is contained in:
xmppftw xmppftw 2024-08-06 20:40:24 +02:00
commit 311e7406f0
11 changed files with 338 additions and 183 deletions

View file

@ -6,6 +6,7 @@ use sasl::client::MechanismError as SaslMechanismError;
use std::error::Error as StdError;
use std::fmt;
use std::io::Error as IoError;
use std::net::AddrParseError;
use std::str::Utf8Error;
use xmpp_parsers::sasl::DefinedCondition as SaslDefinedCondition;
@ -44,6 +45,8 @@ pub enum Error {
/// `idna`
#[cfg(feature = "dns")]
Idna,
/// Invalid IP/Port address
Addr(AddrParseError),
}
impl fmt::Display for Error {
@ -64,6 +67,7 @@ impl fmt::Display for Error {
Error::Resolve(e) => write!(fmt, "{:?}", e),
#[cfg(feature = "dns")]
Error::Idna => write!(fmt, "IDNA error"),
Error::Addr(e) => write!(fmt, "Wrong network address: {e}"),
}
}
}
@ -133,6 +137,12 @@ impl From<DnsProtoError> for Error {
}
}
impl From<AddrParseError> for Error {
fn from(e: AddrParseError) -> Error {
Error::Addr(e)
}
}
/// XMPP protocol-level error
#[derive(Debug)]
pub enum ProtocolError {