fix(window): change commands to async (#385)

pull/387/head
Lucas Fernandes Nogueira 2 years ago committed by GitHub
parent 5914fb9f36
commit f3f92a6ff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -62,7 +62,7 @@ impl From<IconDto> for Icon {
}
#[tauri::command]
pub fn create<R: Runtime>(app: AppHandle<R>, options: WindowConfig) -> Result<()> {
pub async fn create<R: Runtime>(app: AppHandle<R>, options: WindowConfig) -> Result<()> {
tauri::window::WindowBuilder::from_config(&app, options).build()?;
Ok(())
}
@ -77,7 +77,7 @@ fn get_window<R: Runtime>(window: Window<R>, label: Option<String>) -> Result<Wi
macro_rules! getter {
($cmd: ident, $ret: ty) => {
#[tauri::command]
pub fn $cmd<R: Runtime>(window: Window<R>, label: Option<String>) -> Result<$ret> {
pub async fn $cmd<R: Runtime>(window: Window<R>, label: Option<String>) -> 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<R: Runtime>(window: Window<R>, label: Option<String>) -> Result<()> {
pub async fn $cmd<R: Runtime>(window: Window<R>, label: Option<String>) -> Result<()> {
get_window(window, label)?.$cmd().map_err(Into::into)
}
};
($cmd: ident, $input: ty) => {
#[tauri::command]
pub fn $cmd<R: Runtime>(
pub async fn $cmd<R: Runtime>(
window: Window<R>,
label: Option<String>,
value: $input,
@ -151,7 +151,7 @@ setter!(start_dragging);
setter!(print);
#[tauri::command]
pub fn set_icon<R: Runtime>(
pub async fn set_icon<R: Runtime>(
window: Window<R>,
label: Option<String>,
value: IconDto,
@ -162,7 +162,7 @@ pub fn set_icon<R: Runtime>(
}
#[tauri::command]
pub fn toggle_maximize<R: Runtime>(window: Window<R>, label: Option<String>) -> Result<()> {
pub async fn toggle_maximize<R: Runtime>(window: Window<R>, label: Option<String>) -> Result<()> {
let window = get_window(window, label)?;
match window.is_maximized()? {
true => window.unmaximize()?,
@ -172,7 +172,7 @@ pub fn toggle_maximize<R: Runtime>(window: Window<R>, label: Option<String>) ->
}
#[tauri::command]
pub fn internal_toggle_maximize<R: Runtime>(
pub async fn internal_toggle_maximize<R: Runtime>(
window: Window<R>,
label: Option<String>,
) -> Result<()> {
@ -188,7 +188,7 @@ pub fn internal_toggle_maximize<R: Runtime>(
#[cfg(any(debug_assertions, feature = "devtools"))]
#[tauri::command]
pub fn internal_toggle_devtools<R: Runtime>(
pub async fn internal_toggle_devtools<R: Runtime>(
window: Window<R>,
label: Option<String>,
) -> Result<()> {

Loading…
Cancel
Save