use std::str::Utf8Error; use rsasl::mechname::MechanismNameError; use crate::stanza::client::error::Error as ClientError; use crate::{jid::ParseError, stanza::sasl::Failure}; #[derive(Debug)] pub enum Error { Connection, BadStream, StartTlsUnavailable, TlsNegotiation, Utf8Decode, NoFeatures, UnknownNamespace, UnknownAttribute, NoID, NoType, IDMismatch, BindError, ParseError, Negotiation, TlsRequired, UnexpectedEnd, UnexpectedElement(peanuts::Element), UnexpectedText, XML(peanuts::Error), SASL(SASLError), JID(ParseError), Authentication(Failure), ClientError(ClientError), MissingError, } #[derive(Debug)] pub enum SASLError { SASL(rsasl::prelude::SASLError), MechanismName(MechanismNameError), NoChallenge, NoSuccess, } impl From for Error { fn from(e: rsasl::prelude::SASLError) -> Self { Self::SASL(SASLError::SASL(e)) } } impl From for Error { fn from(e: MechanismNameError) -> Self { Self::SASL(SASLError::MechanismName(e)) } } impl From for Error { fn from(e: SASLError) -> Self { Self::SASL(e) } } impl From for Error { fn from(_e: Utf8Error) -> Self { Self::Utf8Decode } } impl From for Error { fn from(e: peanuts::Error) -> Self { Self::XML(e) } } impl From for Error { fn from(e: ParseError) -> Self { Self::JID(e) } }