From 39b2b867f8cf0c52ddb0a8b5979bf995e3ef8742 Mon Sep 17 00:00:00 2001 From: amrbashir Date: Tue, 17 Oct 2023 19:19:40 +0300 Subject: [PATCH 1/2] refactor(core/plugin): inline result type alias --- .../tauri-extranous-result-types-removal.md | 3 ++- core/tauri/src/plugin.rs | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.changes/tauri-extranous-result-types-removal.md b/.changes/tauri-extranous-result-types-removal.md index 3b380a4139db..ad1199945d6a 100644 --- a/.changes/tauri-extranous-result-types-removal.md +++ b/.changes/tauri-extranous-result-types-removal.md @@ -2,4 +2,5 @@ 'tauri': 'major:breaking' --- -Removed `tauri::path::Error` and added its variants to `tauri::Error`. +- Removed `tauri::path::Error` and added its variants to `tauri::Error` +- Removed `tauri::path::Result` and `tauri::plugin::Result` aliases, you should use `tauri::Result` or your own `Result` tye. diff --git a/core/tauri/src/plugin.rs b/core/tauri/src/plugin.rs index e814110f0b2b..3a0ba77358e3 100644 --- a/core/tauri/src/plugin.rs +++ b/core/tauri/src/plugin.rs @@ -16,10 +16,7 @@ use serde_json::Value as JsonValue; use tauri_macros::default_runtime; use url::Url; -use std::{fmt, result::Result as StdResult, sync::Arc}; - -/// The result type of Tauri plugin module. -pub type Result = StdResult>; +use std::{fmt, sync::Arc}; /// Mobile APIs. #[cfg(mobile)] @@ -32,7 +29,11 @@ pub trait Plugin: Send { /// Initializes the plugin. #[allow(unused_variables)] - fn initialize(&mut self, app: &AppHandle, config: JsonValue) -> Result<()> { + fn initialize( + &mut self, + app: &AppHandle, + config: JsonValue, + ) -> Result<(), Box> { Ok(()) } @@ -73,7 +74,8 @@ pub trait Plugin: Send { } } -type SetupHook = dyn FnOnce(&AppHandle, PluginApi) -> Result<()> + Send; +type SetupHook = + dyn FnOnce(&AppHandle, PluginApi) -> Result<(), Box> + Send; type OnWebviewReady = dyn FnMut(Window) + Send; type OnEvent = dyn FnMut(&AppHandle, &RunEvent) + Send; type OnNavigation = dyn Fn(&Window, &Url) -> bool + Send; @@ -320,7 +322,9 @@ impl Builder { #[must_use] pub fn setup(mut self, setup: F) -> Self where - F: FnOnce(&AppHandle, PluginApi) -> Result<()> + Send + 'static, + F: FnOnce(&AppHandle, PluginApi) -> Result<(), Box> + + Send + + 'static, { self.setup.replace(Box::new(setup)); self @@ -500,7 +504,11 @@ impl Plugin for TauriPlugin { self.name } - fn initialize(&mut self, app: &AppHandle, config: JsonValue) -> Result<()> { + fn initialize( + &mut self, + app: &AppHandle, + config: JsonValue, + ) -> Result<(), Box> { self.app.replace(app.clone()); if let Some(s) = self.setup.take() { (s)( From c30ea12f1fe1dbf97486a0c4d483e8c5d565d353 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Tue, 17 Oct 2023 14:32:58 -0300 Subject: [PATCH 2/2] Update .changes/tauri-extranous-result-types-removal.md [skip ci] --- .changes/tauri-extranous-result-types-removal.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/tauri-extranous-result-types-removal.md b/.changes/tauri-extranous-result-types-removal.md index ad1199945d6a..91ef1c3abf29 100644 --- a/.changes/tauri-extranous-result-types-removal.md +++ b/.changes/tauri-extranous-result-types-removal.md @@ -3,4 +3,4 @@ --- - Removed `tauri::path::Error` and added its variants to `tauri::Error` -- Removed `tauri::path::Result` and `tauri::plugin::Result` aliases, you should use `tauri::Result` or your own `Result` tye. +- Removed `tauri::path::Result` and `tauri::plugin::Result` aliases, you should use `tauri::Result` or your own `Result` type.