From f3f92a6ff6a00109694dbc6bc0e56356a8832f35 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Sun, 21 May 2023 13:08:39 -0700 Subject: [PATCH] fix(window): change commands to async (#385) --- plugins/window/src/desktop_commands.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/window/src/desktop_commands.rs b/plugins/window/src/desktop_commands.rs index 98fb60c0..135e8d80 100644 --- a/plugins/window/src/desktop_commands.rs +++ b/plugins/window/src/desktop_commands.rs @@ -62,7 +62,7 @@ impl From for Icon { } #[tauri::command] -pub fn create(app: AppHandle, options: WindowConfig) -> Result<()> { +pub async fn create(app: AppHandle, options: WindowConfig) -> Result<()> { tauri::window::WindowBuilder::from_config(&app, options).build()?; Ok(()) } @@ -77,7 +77,7 @@ fn get_window(window: Window, label: Option) -> Result { #[tauri::command] - pub fn $cmd(window: Window, label: Option) -> Result<$ret> { + pub async fn $cmd(window: Window, label: Option) -> Result<$ret> { get_window(window, label)?.$cmd().map_err(Into::into) } }; @@ -86,14 +86,14 @@ macro_rules! getter { macro_rules! setter { ($cmd: ident) => { #[tauri::command] - pub fn $cmd(window: Window, label: Option) -> Result<()> { + pub async fn $cmd(window: Window, label: Option) -> Result<()> { get_window(window, label)?.$cmd().map_err(Into::into) } }; ($cmd: ident, $input: ty) => { #[tauri::command] - pub fn $cmd( + pub async fn $cmd( window: Window, label: Option, value: $input, @@ -151,7 +151,7 @@ setter!(start_dragging); setter!(print); #[tauri::command] -pub fn set_icon( +pub async fn set_icon( window: Window, label: Option, value: IconDto, @@ -162,7 +162,7 @@ pub fn set_icon( } #[tauri::command] -pub fn toggle_maximize(window: Window, label: Option) -> Result<()> { +pub async fn toggle_maximize(window: Window, label: Option) -> Result<()> { let window = get_window(window, label)?; match window.is_maximized()? { true => window.unmaximize()?, @@ -172,7 +172,7 @@ pub fn toggle_maximize(window: Window, label: Option) -> } #[tauri::command] -pub fn internal_toggle_maximize( +pub async fn internal_toggle_maximize( window: Window, label: Option, ) -> Result<()> { @@ -188,7 +188,7 @@ pub fn internal_toggle_maximize( #[cfg(any(debug_assertions, feature = "devtools"))] #[tauri::command] -pub fn internal_toggle_devtools( +pub async fn internal_toggle_devtools( window: Window, label: Option, ) -> Result<()> {