diff options
| author | 2025-02-25 20:50:23 +0000 | |
|---|---|---|
| committer | 2025-02-25 20:50:23 +0000 | |
| commit | 76b00cd644768d6a1b66b50b802bb72e2be228ce (patch) | |
| tree | bd9e5c6a7df6c00fb68692cdb6b39c6912658054 | |
| parent | d30131e0fcf7d64a333493bc430baa02fd156f4d (diff) | |
| download | luz-76b00cd644768d6a1b66b50b802bb72e2be228ce.tar.gz luz-76b00cd644768d6a1b66b50b802bb72e2be228ce.tar.bz2 luz-76b00cd644768d6a1b66b50b802bb72e2be228ce.zip | |
implement Clone for error types
Diffstat (limited to '')
| -rw-r--r-- | jabber/src/error.rs | 16 | ||||
| -rw-r--r-- | jid/src/lib.rs | 4 | ||||
| -rw-r--r-- | stanza/src/stream.rs | 2 | 
3 files changed, 13 insertions, 9 deletions
| 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<rsasl::prelude::SASLError>),      #[error("mechanism error: {0}")]      MechanismName(#[from] MechanismNameError),      #[error("authentication failure: {0}")]      Authentication(#[from] Failure),  } + +impl From<rsasl::prelude::SASLError> for SASLError { +    fn from(e: rsasl::prelude::SASLError) -> Self { +        Self::SASL(Arc::new(e)) +    } +} diff --git a/jid/src/lib.rs b/jid/src/lib.rs index 09b0a7f..8f297c6 100644 --- a/jid/src/lib.rs +++ b/jid/src/lib.rs @@ -62,7 +62,7 @@ impl sqlx::Encode<'_, Sqlite> for JID {      }  } -#[derive(Debug)] +#[derive(Debug, Clone)]  pub enum JIDError {      NoResourcePart,      ParseError(ParseError), @@ -79,7 +79,7 @@ impl Display for JIDError {  impl Error for JIDError {} -#[derive(Debug)] +#[derive(Debug, Clone)]  pub enum ParseError {      Empty,      Malformed(String), diff --git a/stanza/src/stream.rs b/stanza/src/stream.rs index 60b13bc..8e1982f 100644 --- a/stanza/src/stream.rs +++ b/stanza/src/stream.rs @@ -179,7 +179,7 @@ impl FromElement for Feature {      }  } -#[derive(Error, Debug)] +#[derive(Error, Debug, Clone)]  pub struct Error {      error: StreamError,      text: Option<Text>, | 
