From 76b00cd644768d6a1b66b50b802bb72e2be228ce Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Tue, 25 Feb 2025 20:50:23 +0000 Subject: implement Clone for error types --- jabber/src/error.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'jabber') diff --git a/jabber/src/error.rs b/jabber/src/error.rs index 8c27cc9..ec60778 100644 --- a/jabber/src/error.rs +++ b/jabber/src/error.rs @@ -1,4 +1,5 @@ use std::str::Utf8Error; +use std::sync::Arc; use jid::ParseError; use rsasl::mechname::MechanismNameError; @@ -6,9 +7,8 @@ use stanza::client::error::Error as ClientError; use stanza::sasl::Failure; use stanza::stream::Error as StreamError; use thiserror::Error; -use tokio::task::JoinError; -#[derive(Error, Debug)] +#[derive(Error, Debug, Clone)] pub enum Error { #[error("connection")] Connection, @@ -39,16 +39,20 @@ pub enum Error { StreamError(#[from] StreamError), #[error("error missing")] MissingError, - #[error("task join error")] - JoinError(#[from] JoinError), } -#[derive(Error, Debug)] +#[derive(Error, Debug, Clone)] pub enum SASLError { #[error("sasl error: {0}")] - SASL(#[from] rsasl::prelude::SASLError), + SASL(Arc), #[error("mechanism error: {0}")] MechanismName(#[from] MechanismNameError), #[error("authentication failure: {0}")] Authentication(#[from] Failure), } + +impl From for SASLError { + fn from(e: rsasl::prelude::SASLError) -> Self { + Self::SASL(Arc::new(e)) + } +} -- cgit