Explorar o código

drop Sync req from `setup` and `setup_with_config` (#3471)

Jonas Kruckenberg %!s(int64=3) %!d(string=hai) anos
pai
achega
fb7ee2c987
Modificáronse 2 ficheiros con 9 adicións e 4 borrados
  1. 5 0
      .changes/fix-drop-sync.md
  2. 4 4
      core/tauri/src/plugin.rs

+ 5 - 0
.changes/fix-drop-sync.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Callbacks passed to `tauri::plugin::Builder::setup` or `tauri::plugin::Builder::setup_with_config` are no longer required to implement `Sync`.

+ 4 - 4
core/tauri/src/plugin.rs

@@ -54,8 +54,8 @@ pub trait Plugin<R: Runtime>: Send {
   fn extend_api(&mut self, invoke: Invoke<R>) {}
 }
 
-type SetupHook<R> = dyn FnOnce(&AppHandle<R>) -> Result<()> + Send + Sync;
-type SetupWithConfigHook<R, T> = dyn FnOnce(&AppHandle<R>, T) -> Result<()> + Send + Sync;
+type SetupHook<R> = dyn FnOnce(&AppHandle<R>) -> Result<()> + Send;
+type SetupWithConfigHook<R, T> = dyn FnOnce(&AppHandle<R>, T) -> Result<()> + Send;
 type OnWebviewReady<R> = dyn FnMut(Window<R>) + Send + Sync;
 type OnEvent<R> = dyn FnMut(&AppHandle<R>, &RunEvent) + Send + Sync;
 type OnPageLoad<R> = dyn FnMut(Window<R>, PageLoadPayload) + Send + Sync;
@@ -251,7 +251,7 @@ impl<R: Runtime, C: DeserializeOwned> Builder<R, C> {
   #[must_use]
   pub fn setup<F>(mut self, setup: F) -> Self
   where
-    F: FnOnce(&AppHandle<R>) -> Result<()> + Send + Sync + 'static,
+    F: FnOnce(&AppHandle<R>) -> Result<()> + Send + 'static,
   {
     self.setup.replace(Box::new(setup));
     self
@@ -287,7 +287,7 @@ impl<R: Runtime, C: DeserializeOwned> Builder<R, C> {
   #[must_use]
   pub fn setup_with_config<F>(mut self, setup_with_config: F) -> Self
   where
-    F: FnOnce(&AppHandle<R>, C) -> Result<()> + Send + Sync + 'static,
+    F: FnOnce(&AppHandle<R>, C) -> Result<()> + Send + 'static,
   {
     self.setup_with_config.replace(Box::new(setup_with_config));
     self