From fb7ee2c987d9fca23f08bd470789069d9477c66e Mon Sep 17 00:00:00 2001 From: Jonas Kruckenberg Date: Wed, 16 Feb 2022 14:06:56 +0100 Subject: [PATCH] drop Sync req from `setup` and `setup_with_config` (#3471) --- .changes/fix-drop-sync.md | 5 +++++ core/tauri/src/plugin.rs | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changes/fix-drop-sync.md diff --git a/.changes/fix-drop-sync.md b/.changes/fix-drop-sync.md new file mode 100644 index 000000000..e468a8236 --- /dev/null +++ b/.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`. diff --git a/core/tauri/src/plugin.rs b/core/tauri/src/plugin.rs index b980e73af..df0b0ed34 100644 --- a/core/tauri/src/plugin.rs +++ b/core/tauri/src/plugin.rs @@ -54,8 +54,8 @@ pub trait Plugin: Send { fn extend_api(&mut self, invoke: Invoke) {} } -type SetupHook = dyn FnOnce(&AppHandle) -> Result<()> + Send + Sync; -type SetupWithConfigHook = dyn FnOnce(&AppHandle, T) -> Result<()> + Send + Sync; +type SetupHook = dyn FnOnce(&AppHandle) -> Result<()> + Send; +type SetupWithConfigHook = dyn FnOnce(&AppHandle, T) -> Result<()> + Send; type OnWebviewReady = dyn FnMut(Window) + Send + Sync; type OnEvent = dyn FnMut(&AppHandle, &RunEvent) + Send + Sync; type OnPageLoad = dyn FnMut(Window, PageLoadPayload) + Send + Sync; @@ -251,7 +251,7 @@ impl Builder { #[must_use] pub fn setup(mut self, setup: F) -> Self where - F: FnOnce(&AppHandle) -> Result<()> + Send + Sync + 'static, + F: FnOnce(&AppHandle) -> Result<()> + Send + 'static, { self.setup.replace(Box::new(setup)); self @@ -287,7 +287,7 @@ impl Builder { #[must_use] pub fn setup_with_config(mut self, setup_with_config: F) -> Self where - F: FnOnce(&AppHandle, C) -> Result<()> + Send + Sync + 'static, + F: FnOnce(&AppHandle, C) -> Result<()> + Send + 'static, { self.setup_with_config.replace(Box::new(setup_with_config)); self