From 2e6db908d7b3a2c928c46b0ad9ccf9ec55a29480 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Mon, 5 Feb 2024 19:52:10 +0200 Subject: [PATCH] fix(core): make `tauri::Error` sync again (#8777) * fix(core): make `tauri::Error` sync again closes #8754 * add unit test --------- Co-authored-by: Lucas Nogueira --- .changes/tauri-error-sync.md | 5 +++++ .changes/tauri-scope-object-error-sync.md | 5 +++++ core/tauri/src/error.rs | 11 ++++++++++- core/tauri/src/ipc/authority.rs | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .changes/tauri-error-sync.md create mode 100644 .changes/tauri-scope-object-error-sync.md diff --git a/.changes/tauri-error-sync.md b/.changes/tauri-error-sync.md new file mode 100644 index 000000000..3fb1c3e88 --- /dev/null +++ b/.changes/tauri-error-sync.md @@ -0,0 +1,5 @@ +--- +'tauri': 'patch:bug' +--- + +Fix regression in `tauri::Error` not being `Sync`. diff --git a/.changes/tauri-scope-object-error-sync.md b/.changes/tauri-scope-object-error-sync.md new file mode 100644 index 000000000..8af76397d --- /dev/null +++ b/.changes/tauri-scope-object-error-sync.md @@ -0,0 +1,5 @@ +--- +'tauri': 'patch:breaking' +--- + +Require `ScopeObject::Error` to be `Sync` as well. diff --git a/core/tauri/src/error.rs b/core/tauri/src/error.rs index fc62f5018..933b2449a 100644 --- a/core/tauri/src/error.rs +++ b/core/tauri/src/error.rs @@ -147,8 +147,17 @@ pub enum Error { UnstableFeatureNotSupported, /// Failed to deserialize scope object. #[error("error deserializing scope: {0}")] - CannotDeserializeScope(Box), + CannotDeserializeScope(Box), } /// `Result` pub type Result = std::result::Result; + +#[cfg(test)] +mod tests { + #[test] + fn error_is_send_sync() { + crate::test_utils::assert_send::(); + crate::test_utils::assert_sync::(); + } +} diff --git a/core/tauri/src/ipc/authority.rs b/core/tauri/src/ipc/authority.rs index 67dc947c5..1ff3f4a91 100644 --- a/core/tauri/src/ipc/authority.rs +++ b/core/tauri/src/ipc/authority.rs @@ -363,7 +363,7 @@ pub struct ScopeManager { /// though this is useful if you need to do some initialization logic on the type itself. pub trait ScopeObject: Sized + Send + Sync + Debug + 'static { /// The error type. - type Error: std::error::Error + Send; + type Error: std::error::Error + Send + Sync; /// Deserialize the raw scope value. fn deserialize(app: &AppHandle, raw: Value) -> Result; }