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 <lucas@tauri.studio>
This commit is contained in:
Amr Bashir 2024-02-05 19:52:10 +02:00 committed by GitHub
parent 19fb5f0b20
commit 2e6db908d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
'tauri': 'patch:bug'
---
Fix regression in `tauri::Error` not being `Sync`.

View File

@ -0,0 +1,5 @@
---
'tauri': 'patch:breaking'
---
Require `ScopeObject::Error` to be `Sync` as well.

View File

@ -147,8 +147,17 @@ pub enum Error {
UnstableFeatureNotSupported,
/// Failed to deserialize scope object.
#[error("error deserializing scope: {0}")]
CannotDeserializeScope(Box<dyn std::error::Error + Send>),
CannotDeserializeScope(Box<dyn std::error::Error + Send + Sync>),
}
/// `Result<T, ::tauri::Error>`
pub type Result<T> = std::result::Result<T, Error>;
#[cfg(test)]
mod tests {
#[test]
fn error_is_send_sync() {
crate::test_utils::assert_send::<super::Error>();
crate::test_utils::assert_sync::<super::Error>();
}
}

View File

@ -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<R: Runtime>(app: &AppHandle<R>, raw: Value) -> Result<Self, Self::Error>;
}