diff --git a/.changes/tauri-extranous-result-types-removal.md b/.changes/tauri-extranous-result-types-removal.md index 3b380a4139db..91ef1c3abf29 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` type. 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)(