aboutsummaryrefslogtreecommitdiffstats
path: root/jabber/src/error.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2024-12-04 18:18:37 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2024-12-04 18:18:37 +0000
commit1b91ff690488b65b552c90bd5392b9a300c8c981 (patch)
tree9c290f69b26eba0393d7bbc05ba29c28ea74a26e /jabber/src/error.rs
parent03764f8cedb3f0a55a61be0f0a59faaa6357a83a (diff)
downloadluz-1b91ff690488b65b552c90bd5392b9a300c8c981.tar.gz
luz-1b91ff690488b65b552c90bd5392b9a300c8c981.tar.bz2
luz-1b91ff690488b65b552c90bd5392b9a300c8c981.zip
use cargo workspace
Diffstat (limited to 'jabber/src/error.rs')
-rw-r--r--jabber/src/error.rs78
1 files changed, 78 insertions, 0 deletions
diff --git a/jabber/src/error.rs b/jabber/src/error.rs
new file mode 100644
index 0000000..aad033c
--- /dev/null
+++ b/jabber/src/error.rs
@@ -0,0 +1,78 @@
+use std::str::Utf8Error;
+
+use jid::ParseError;
+use rsasl::mechname::MechanismNameError;
+use stanza::client::error::Error as ClientError;
+use stanza::sasl::Failure;
+use stanza::stream::Error as StreamError;
+
+#[derive(Debug)]
+pub enum Error {
+ Connection,
+ Utf8Decode,
+ Negotiation,
+ TlsRequired,
+ AlreadyTls,
+ Unsupported,
+ NoLocalpart,
+ AlreadyConnecting,
+ UnexpectedElement(peanuts::Element),
+ XML(peanuts::Error),
+ Deserialization(peanuts::DeserializeError),
+ SASL(SASLError),
+ JID(ParseError),
+ Authentication(Failure),
+ ClientError(ClientError),
+ StreamError(StreamError),
+ MissingError,
+ Disconnected,
+ Connecting,
+}
+
+#[derive(Debug)]
+pub enum SASLError {
+ SASL(rsasl::prelude::SASLError),
+ MechanismName(MechanismNameError),
+}
+
+impl From<rsasl::prelude::SASLError> for Error {
+ fn from(e: rsasl::prelude::SASLError) -> Self {
+ Self::SASL(SASLError::SASL(e))
+ }
+}
+
+impl From<peanuts::DeserializeError> for Error {
+ fn from(e: peanuts::DeserializeError) -> Self {
+ Error::Deserialization(e)
+ }
+}
+
+impl From<MechanismNameError> for Error {
+ fn from(e: MechanismNameError) -> Self {
+ Self::SASL(SASLError::MechanismName(e))
+ }
+}
+
+impl From<SASLError> for Error {
+ fn from(e: SASLError) -> Self {
+ Self::SASL(e)
+ }
+}
+
+impl From<Utf8Error> for Error {
+ fn from(_e: Utf8Error) -> Self {
+ Self::Utf8Decode
+ }
+}
+
+impl From<peanuts::Error> for Error {
+ fn from(e: peanuts::Error) -> Self {
+ Self::XML(e)
+ }
+}
+
+impl From<ParseError> for Error {
+ fn from(e: ParseError) -> Self {
+ Self::JID(e)
+ }
+}