diff --git a/Cargo.toml b/Cargo.toml index ab5202f4b..5ef77bfe4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ glob = "0.3" zbus = "5.9" [workspace.package] -edition = "2021" +edition = "2024" authors = ["Tauri Programme within The Commons Conservancy"] license = "Apache-2.0 OR MIT" rust-version = "1.90" diff --git a/examples/api/src-tauri/Cargo.toml b/examples/api/src-tauri/Cargo.toml index 0d3b3b1ca..8e06d3c4f 100644 --- a/examples/api/src-tauri/Cargo.toml +++ b/examples/api/src-tauri/Cargo.toml @@ -3,7 +3,7 @@ name = "api" publish = false version = "2.0.49" description = "An example Tauri Application showcasing the api" -edition = "2021" +edition = "2024" rust-version = { workspace = true } license = "Apache-2.0 OR MIT" diff --git a/examples/api/src-tauri/src/lib.rs b/examples/api/src-tauri/src/lib.rs index cb858201a..2cb8d927d 100644 --- a/examples/api/src-tauri/src/lib.rs +++ b/examples/api/src-tauri/src/lib.rs @@ -8,8 +8,8 @@ mod tray; use serde::Serialize; use tauri::{ - webview::{PageLoadEvent, WebviewWindowBuilder}, App, AppHandle, Emitter, Listener, RunEvent, WebviewUrl, + webview::{PageLoadEvent, WebviewWindowBuilder}, }; #[derive(Clone, Serialize)] @@ -204,12 +204,11 @@ pub fn run() { app.run(move |_app_handle, _event| { #[cfg(desktop)] - if let RunEvent::ExitRequested { code, api, .. } = &_event { - if code.is_none() { + if let RunEvent::ExitRequested { code, api, .. } = &_event + && code.is_none() { // Keep the event loop running even if all windows are closed // This allow us to catch system tray events when there is no window api.prevent_exit(); } - } }) } diff --git a/examples/api/src-tauri/src/tray.rs b/examples/api/src-tauri/src/tray.rs index ba4a5a003..f0fdff344 100644 --- a/examples/api/src-tauri/src/tray.rs +++ b/examples/api/src-tauri/src/tray.rs @@ -4,9 +4,9 @@ use std::sync::atomic::{AtomicBool, Ordering}; use tauri::{ + Manager, Runtime, WebviewUrl, WebviewWindowBuilder, menu::{Menu, MenuItem}, tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent}, - Manager, Runtime, WebviewUrl, WebviewWindowBuilder, }; pub fn create_tray(app: &tauri::AppHandle) -> tauri::Result<()> { diff --git a/plugins/autostart/src/lib.rs b/plugins/autostart/src/lib.rs index af9ef7564..e92fa62c0 100644 --- a/plugins/autostart/src/lib.rs +++ b/plugins/autostart/src/lib.rs @@ -11,11 +11,10 @@ #![cfg(not(any(target_os = "android", target_os = "ios")))] use auto_launch::{AutoLaunch, AutoLaunchBuilder}; -use serde::{ser::Serializer, Serialize}; +use serde::{Serialize, ser::Serializer}; use tauri::{ - command, + Manager, Runtime, State, command, plugin::{Builder as PluginBuilder, TauriPlugin}, - Manager, Runtime, State, }; use std::env::current_exe; diff --git a/plugins/barcode-scanner/src/error.rs b/plugins/barcode-scanner/src/error.rs index 5aabafd92..17d502e6a 100644 --- a/plugins/barcode-scanner/src/error.rs +++ b/plugins/barcode-scanner/src/error.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{ser::Serializer, Serialize}; +use serde::{Serialize, ser::Serializer}; /// Alias for the result type returned by this crate's functions. pub type Result = std::result::Result; diff --git a/plugins/barcode-scanner/src/lib.rs b/plugins/barcode-scanner/src/lib.rs index 0266b7e38..fb6a89257 100644 --- a/plugins/barcode-scanner/src/lib.rs +++ b/plugins/barcode-scanner/src/lib.rs @@ -9,8 +9,8 @@ #![cfg(mobile)] use tauri::{ - plugin::{Builder, PluginHandle, TauriPlugin}, Manager, Runtime, + plugin::{Builder, PluginHandle, TauriPlugin}, }; pub use models::*; diff --git a/plugins/biometric/src/error.rs b/plugins/biometric/src/error.rs index 1be5a6639..8fbd0bd11 100644 --- a/plugins/biometric/src/error.rs +++ b/plugins/biometric/src/error.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{ser::Serializer, Serialize}; +use serde::{Serialize, ser::Serializer}; /// Alias for a [`Result`](std::result::Result) with the error type [`Error`]. pub type Result = std::result::Result; diff --git a/plugins/biometric/src/lib.rs b/plugins/biometric/src/lib.rs index 01303d514..03f3fc1d7 100644 --- a/plugins/biometric/src/lib.rs +++ b/plugins/biometric/src/lib.rs @@ -10,8 +10,8 @@ use serde::Serialize; use tauri::{ - plugin::{Builder, PluginHandle, TauriPlugin}, Manager, Runtime, + plugin::{Builder, PluginHandle, TauriPlugin}, }; pub use models::*; diff --git a/plugins/cli/src/lib.rs b/plugins/cli/src/lib.rs index ad133672f..7857b0518 100644 --- a/plugins/cli/src/lib.rs +++ b/plugins/cli/src/lib.rs @@ -12,8 +12,8 @@ )] use tauri::{ - plugin::{Builder, PluginApi, TauriPlugin}, AppHandle, Manager, Runtime, State, + plugin::{Builder, PluginApi, TauriPlugin}, }; mod config; diff --git a/plugins/cli/src/parser.rs b/plugins/cli/src/parser.rs index 466885f14..1c66adb52 100644 --- a/plugins/cli/src/parser.rs +++ b/plugins/cli/src/parser.rs @@ -3,9 +3,9 @@ // SPDX-License-Identifier: MIT use clap::{ + Arg as ClapArg, ArgAction, ArgMatches, Command, builder::{PossibleValue, PossibleValuesParser}, error::ErrorKind, - Arg as ClapArg, ArgAction, ArgMatches, Command, }; use serde::Serialize; use serde_json::Value; @@ -134,8 +134,8 @@ fn get_matches_internal(config: &Config, matches: &ArgMatches) -> Matches { let mut cli_matches = Matches::default(); map_matches(config, matches, &mut cli_matches); - if let Some((subcommand_name, subcommand_matches)) = matches.subcommand() { - if let Some(subcommand_config) = config + if let Some((subcommand_name, subcommand_matches)) = matches.subcommand() + && let Some(subcommand_config) = config .subcommands .as_ref() .and_then(|s| s.get(subcommand_name)) @@ -145,7 +145,6 @@ fn get_matches_internal(config: &Config, matches: &ArgMatches) -> Matches { get_matches_internal(subcommand_config, subcommand_matches), ); } - } cli_matches } diff --git a/plugins/clipboard-manager/src/commands.rs b/plugins/clipboard-manager/src/commands.rs index a8dd94ac0..a903e9844 100644 --- a/plugins/clipboard-manager/src/commands.rs +++ b/plugins/clipboard-manager/src/commands.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use tauri::{command, image::JsImage, AppHandle, Manager, ResourceId, Runtime, State, Webview}; +use tauri::{AppHandle, Manager, ResourceId, Runtime, State, Webview, command, image::JsImage}; use crate::{Clipboard, Result}; diff --git a/plugins/clipboard-manager/src/desktop.rs b/plugins/clipboard-manager/src/desktop.rs index b31b509cd..6cb1ca9b7 100644 --- a/plugins/clipboard-manager/src/desktop.rs +++ b/plugins/clipboard-manager/src/desktop.rs @@ -4,7 +4,7 @@ use arboard::ImageData; use serde::de::DeserializeOwned; -use tauri::{image::Image, plugin::PluginApi, AppHandle, Runtime}; +use tauri::{AppHandle, Runtime, image::Image, plugin::PluginApi}; use std::{borrow::Cow, sync::Mutex}; diff --git a/plugins/clipboard-manager/src/error.rs b/plugins/clipboard-manager/src/error.rs index 6f7e6c4d9..e945f9874 100644 --- a/plugins/clipboard-manager/src/error.rs +++ b/plugins/clipboard-manager/src/error.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{ser::Serializer, Serialize}; +use serde::{Serialize, ser::Serializer}; /// Alias for `Result` used throughout this crate. pub type Result = std::result::Result; diff --git a/plugins/clipboard-manager/src/lib.rs b/plugins/clipboard-manager/src/lib.rs index 84ea87e43..d08d77c2c 100644 --- a/plugins/clipboard-manager/src/lib.rs +++ b/plugins/clipboard-manager/src/lib.rs @@ -10,8 +10,8 @@ )] use tauri::{ - plugin::{Builder, TauriPlugin}, Manager, RunEvent, Runtime, + plugin::{Builder, TauriPlugin}, }; #[cfg(desktop)] diff --git a/plugins/clipboard-manager/src/mobile.rs b/plugins/clipboard-manager/src/mobile.rs index 7eae15552..bb71b6ce7 100644 --- a/plugins/clipboard-manager/src/mobile.rs +++ b/plugins/clipboard-manager/src/mobile.rs @@ -5,9 +5,9 @@ use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use tauri::{ + AppHandle, Runtime, image::Image, plugin::{PluginApi, PluginHandle}, - AppHandle, Runtime, }; use std::borrow::Cow; diff --git a/plugins/deep-link/examples/app/src-tauri/Cargo.toml b/plugins/deep-link/examples/app/src-tauri/Cargo.toml index 8fd27f851..25947bb7e 100644 --- a/plugins/deep-link/examples/app/src-tauri/Cargo.toml +++ b/plugins/deep-link/examples/app/src-tauri/Cargo.toml @@ -5,7 +5,7 @@ description = "A Tauri App" authors = ["you"] license = "" repository = "" -edition = "2021" +edition = "2024" rust-version = "1.90" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/plugins/deep-link/src/commands.rs b/plugins/deep-link/src/commands.rs index 078adfb1e..31d852f9c 100644 --- a/plugins/deep-link/src/commands.rs +++ b/plugins/deep-link/src/commands.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use tauri::{command, AppHandle, Runtime, State, Window}; +use tauri::{AppHandle, Runtime, State, Window, command}; use crate::{DeepLink, Result}; diff --git a/plugins/deep-link/src/config.rs b/plugins/deep-link/src/config.rs index 49de68e3d..94aba9092 100644 --- a/plugins/deep-link/src/config.rs +++ b/plugins/deep-link/src/config.rs @@ -50,7 +50,9 @@ impl AssociatedDomain { } if self.scheme.iter().any(|s| s == "http") && !self.scheme.iter().any(|s| s == "https") { - eprintln!("Warning: AppLink uses only 'http' — allowed on Android but not secure for production."); + eprintln!( + "Warning: AppLink uses only 'http' — allowed on Android but not secure for production." + ); } } @@ -68,13 +70,12 @@ where D: Deserializer<'de>, { let opt = Option::::deserialize(deserializer)?; - if let Some(ref host) = opt { - if let Some((scheme, _)) = host.split_once("://") { + if let Some(ref host) = opt + && let Some((scheme, _)) = host.split_once("://") { return Err(serde::de::Error::custom(format!( "host `{host}` cannot start with a scheme, please remove the `{scheme}://` prefix" ))); } - } Ok(opt) } diff --git a/plugins/deep-link/src/error.rs b/plugins/deep-link/src/error.rs index 7832995fe..30138965f 100644 --- a/plugins/deep-link/src/error.rs +++ b/plugins/deep-link/src/error.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{ser::Serializer, Serialize}; +use serde::{Serialize, ser::Serializer}; /// Alias for a [`Result`](std::result::Result) with the error type [`Error`]. pub type Result = std::result::Result; diff --git a/plugins/deep-link/src/lib.rs b/plugins/deep-link/src/lib.rs index 9796060a6..1b7ca9e1d 100644 --- a/plugins/deep-link/src/lib.rs +++ b/plugins/deep-link/src/lib.rs @@ -11,8 +11,8 @@ //! calling those methods returns [`Error::UnsupportedPlatform`]. use tauri::{ - plugin::{Builder, PluginApi, TauriPlugin}, AppHandle, EventId, Listener, Manager, Runtime, + plugin::{Builder, PluginApi, TauriPlugin}, }; mod commands; @@ -33,8 +33,8 @@ fn init_deep_link( let _api = api; use tauri::{ - ipc::{Channel, InvokeResponseBody}, Emitter, + ipc::{Channel, InvokeResponseBody}, }; let handle = _api.register_android_plugin(PLUGIN_IDENTIFIER, "DeepLinkPlugin")?; @@ -94,7 +94,7 @@ fn init_deep_link( #[cfg(target_os = "android")] mod imp { - use tauri::{ipc::Channel, plugin::PluginHandle, AppHandle, Runtime}; + use tauri::{AppHandle, Runtime, ipc::Channel, plugin::PluginHandle}; use serde::{Deserialize, Serialize}; @@ -172,7 +172,7 @@ mod imp { use std::sync::Mutex; #[cfg(target_os = "linux")] use std::{ - fs::{create_dir_all, File}, + fs::{File, create_dir_all}, io::Write, process::Command, }; @@ -223,7 +223,9 @@ mod imp { current.replace(vec![url.clone()]); let _ = self.app.emit("deep-link://new-url", vec![url]); } else if cfg!(debug_assertions) { - tracing::warn!("argument {url} does not match any configured deep link scheme; skipping it"); + tracing::warn!( + "argument {url} does not match any configured deep link scheme; skipping it" + ); } } } @@ -414,11 +416,10 @@ mod imp { let mimeapps_path = self.app.path().config_dir()?.join("mimeapps.list"); if mimeapps_path.exists() { let mut mimeapps = ini::Ini::load_from_file(&mimeapps_path)?; - if let Some(section) = mimeapps.section_mut(Some("Default Applications")) { - if section.get(&mime_type).unwrap_or_default() == file_name { + if let Some(section) = mimeapps.section_mut(Some("Default Applications")) + && section.get(&mime_type).unwrap_or_default() == file_name { section.remove(&mime_type); } - } mimeapps.write_to_file(&mimeapps_path)?; } @@ -558,16 +559,16 @@ impl DeepLink { /// /// Use `get_current` on app load to check whether your app was started via a deep link. pub fn on_open_url(&self, f: F) -> EventId { - let event_id = self.app.listen("deep-link://new-url", move |event| { + + + self.app.listen("deep-link://new-url", move |event| { if let Ok(urls) = serde_json::from_str(event.payload()) { f(OpenUrlEvent { id: event.id(), urls, }) } - }); - - event_id + }) } } diff --git a/plugins/dialog/src/commands.rs b/plugins/dialog/src/commands.rs index 2564a1aa0..1411f909c 100644 --- a/plugins/dialog/src/commands.rs +++ b/plugins/dialog/src/commands.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use serde::{Deserialize, Serialize}; -use tauri::{command, Manager, Runtime, State, Window}; +use tauri::{Manager, Runtime, State, Window, command}; use tauri_plugin_fs::FsExt; use crate::{ @@ -171,14 +171,13 @@ pub(crate) async fn open( ) } else { let folder = dialog_builder.blocking_pick_folder(); - if let Some(folder) = &folder { - if let Ok(path) = folder.clone().into_path() { + if let Some(folder) = &folder + && let Ok(path) = folder.clone().into_path() { if let Some(s) = window.try_fs_scope() { s.allow_directory(&path, options.recursive)?; } tauri_scope.allow_directory(&path, options.directory)?; } - } OpenResponse::Folder(folder.map(|p| p.simplified())) } } @@ -204,14 +203,13 @@ pub(crate) async fn open( let tauri_scope = window.state::(); let file = dialog_builder.blocking_pick_file(); - if let Some(file) = &file { - if let Ok(path) = file.clone().into_path() { + if let Some(file) = &file + && let Ok(path) = file.clone().into_path() { if let Some(s) = window.try_fs_scope() { s.allow_file(&path)?; } tauri_scope.allow_file(&path)?; } - } OpenResponse::File(file.map(|f| f.simplified())) }; Ok(res) @@ -246,14 +244,13 @@ pub(crate) async fn save( let tauri_scope = window.state::(); let path = dialog_builder.blocking_save_file(); - if let Some(p) = &path { - if let Ok(path) = p.clone().into_path() { + if let Some(p) = &path + && let Ok(path) = p.clone().into_path() { if let Some(s) = window.try_fs_scope() { s.allow_file(&path)?; } tauri_scope.allow_file(&path)?; } - } Ok(path.map(|p| p.simplified())) } diff --git a/plugins/dialog/src/desktop.rs b/plugins/dialog/src/desktop.rs index 8d3b08f95..3a6c27270 100644 --- a/plugins/dialog/src/desktop.rs +++ b/plugins/dialog/src/desktop.rs @@ -11,9 +11,9 @@ use raw_window_handle::{HasDisplayHandle, HasWindowHandle, RawDisplayHandle, RawWindowHandle}; use rfd::{AsyncFileDialog, AsyncMessageDialog}; use serde::de::DeserializeOwned; -use tauri::{plugin::PluginApi, AppHandle, Runtime}; +use tauri::{AppHandle, Runtime, plugin::PluginApi}; -use crate::{models::*, FileDialogBuilder, FilePath, MessageDialogBuilder}; +use crate::{FileDialogBuilder, FilePath, MessageDialogBuilder, models::*}; pub fn init( app: &AppHandle, diff --git a/plugins/dialog/src/error.rs b/plugins/dialog/src/error.rs index dac05b179..97583e535 100644 --- a/plugins/dialog/src/error.rs +++ b/plugins/dialog/src/error.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{ser::Serializer, Serialize}; +use serde::{Serialize, ser::Serializer}; /// Alias for `Result` used throughout this crate. pub type Result = std::result::Result; diff --git a/plugins/dialog/src/lib.rs b/plugins/dialog/src/lib.rs index 0e092af0a..7cfad33b1 100644 --- a/plugins/dialog/src/lib.rs +++ b/plugins/dialog/src/lib.rs @@ -16,8 +16,8 @@ use serde::{Deserialize, Serialize}; use tauri::{ - plugin::{Builder, TauriPlugin}, Manager, Runtime, + plugin::{Builder, TauriPlugin}, }; use std::{ diff --git a/plugins/dialog/src/mobile.rs b/plugins/dialog/src/mobile.rs index 46ea3a276..7718af21e 100644 --- a/plugins/dialog/src/mobile.rs +++ b/plugins/dialog/src/mobile.rs @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{de::DeserializeOwned, Deserialize}; +use serde::{Deserialize, de::DeserializeOwned}; use tauri::{ - plugin::{PluginApi, PluginHandle}, AppHandle, Runtime, + plugin::{PluginApi, PluginHandle}, }; use crate::{FileDialogBuilder, FilePath, MessageDialogBuilder, MessageDialogResult}; diff --git a/plugins/fs/src/android.rs b/plugins/fs/src/android.rs index d00b4fc52..a914b4d9c 100644 --- a/plugins/fs/src/android.rs +++ b/plugins/fs/src/android.rs @@ -3,9 +3,9 @@ // SPDX-License-Identifier: MIT use serde::de::DeserializeOwned; -use tauri::{plugin::PluginApi, AppHandle, Runtime}; +use tauri::{AppHandle, Runtime, plugin::PluginApi}; -use crate::{models::*, FilePath, OpenOptions}; +use crate::{FilePath, OpenOptions, models::*}; const PLUGIN_IDENTIFIER: &str = "com.plugin.fs"; diff --git a/plugins/fs/src/commands.rs b/plugins/fs/src/commands.rs index 00cf98ad3..9065efa7c 100644 --- a/plugins/fs/src/commands.rs +++ b/plugins/fs/src/commands.rs @@ -6,10 +6,10 @@ use serde::{Deserialize, Serialize, Serializer}; use serde_repr::{Deserialize_repr, Serialize_repr}; use tauri::{ + Manager, Resource, ResourceId, Runtime, Webview, ipc::{CommandScope, GlobalScope}, path::BaseDirectory, utils::config::FsScope, - Manager, Resource, ResourceId, Runtime, Webview, }; use std::{ @@ -23,7 +23,7 @@ use std::{ time::{SystemTime, UNIX_EPOCH}, }; -use crate::{scope::Entry, Error, SafeFilePath}; +use crate::{Error, SafeFilePath, scope::Entry}; #[derive(Debug, thiserror::Error)] pub enum CommandError { @@ -175,7 +175,9 @@ impl Drop for FileHandle { .stop_accessing_security_scoped_resource(FilePath::Url(url.clone())); security_scoped_resources.remove(url.as_str()); } else { - log::debug!("Not cleaning up security-scoped resource for URL: {url} on drop (manually tracked via start_accessing_security_scoped_resource)"); + log::debug!( + "Not cleaning up security-scoped resource for URL: {url} on drop (manually tracked via start_accessing_security_scoped_resource)" + ); } } } @@ -251,7 +253,9 @@ impl Drop for PathHandle { .stop_accessing_security_scoped_resource(FilePath::Url(url.clone())); security_scoped_resources.remove(url.as_str()); } else { - log::debug!("Not cleaning up security-scoped resource for URL: {url} on drop (manually tracked via start_accessing_security_scoped_resource)"); + log::debug!( + "Not cleaning up security-scoped resource for URL: {url} on drop (manually tracked via start_accessing_security_scoped_resource)" + ); } } } @@ -1530,7 +1534,10 @@ pub fn resolve_path( unsafe { let success = ns_url.startAccessingSecurityScopedResource(); if success { - log::debug!("Started accessing security-scoped resource for URL: {} (via resolve_path)", url.as_str()); + log::debug!( + "Started accessing security-scoped resource for URL: {} (via resolve_path)", + url.as_str() + ); // Track it so we know to clean it up security_scoped_resources.track_manually(url.as_str().to_string()); } else { @@ -1541,10 +1548,16 @@ pub fn resolve_path( } } } else { - log::debug!("Failed to create NSURL from URL: {}, ignoring security-scoped resource access request", url.as_str()); + log::debug!( + "Failed to create NSURL from URL: {}, ignoring security-scoped resource access request", + url.as_str() + ); } } else { - log::debug!("Security-scoped resource already active for URL: {} (started via start_accessing_security_scoped_resource), skipping", url.as_str()); + log::debug!( + "Security-scoped resource already active for URL: {} (started via start_accessing_security_scoped_resource), skipping", + url.as_str() + ); } } } diff --git a/plugins/fs/src/file_path.rs b/plugins/fs/src/file_path.rs index 6316a2489..7252b0d3a 100644 --- a/plugins/fs/src/file_path.rs +++ b/plugins/fs/src/file_path.rs @@ -190,11 +190,10 @@ impl<'de> serde::Deserialize<'de> for SafeFilePath { impl FromStr for FilePath { type Err = Infallible; fn from_str(s: &str) -> std::result::Result { - if let Ok(url) = url::Url::from_str(s) { - if url.scheme().len() != 1 { + if let Ok(url) = url::Url::from_str(s) + && url.scheme().len() != 1 { return Ok(Self::Url(url)); } - } Ok(Self::Path(PathBuf::from(s))) } } @@ -202,11 +201,10 @@ impl FromStr for FilePath { impl FromStr for SafeFilePath { type Err = Error; fn from_str(s: &str) -> Result { - if let Ok(url) = url::Url::from_str(s) { - if url.scheme().len() != 1 { + if let Ok(url) = url::Url::from_str(s) + && url.scheme().len() != 1 { return Ok(Self::Url(url)); } - } SafePathBuf::new(s.into()) .map(SafeFilePath::Path) diff --git a/plugins/fs/src/ios.rs b/plugins/fs/src/ios.rs index fa8936181..7c1fc271b 100644 --- a/plugins/fs/src/ios.rs +++ b/plugins/fs/src/ios.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use serde::de::DeserializeOwned; -use tauri::{plugin::PluginApi, AppHandle, Runtime}; +use tauri::{AppHandle, Runtime, plugin::PluginApi}; use crate::{FilePath, OpenOptions}; @@ -69,7 +69,10 @@ impl Fs { } } } else { - log::debug!("Failed to create NSURL from URL: {}, ignoring security-scoped resource access request", url_string); + log::debug!( + "Failed to create NSURL from URL: {}, ignoring security-scoped resource access request", + url_string + ); } // Convert URL to path and open the file diff --git a/plugins/fs/src/lib.rs b/plugins/fs/src/lib.rs index 7f57f11cb..ed7854c21 100644 --- a/plugins/fs/src/lib.rs +++ b/plugins/fs/src/lib.rs @@ -22,10 +22,10 @@ use std::sync::Mutex; use serde::Deserialize; use tauri::{ + AppHandle, DragDropEvent, Manager, RunEvent, Runtime, WindowEvent, ipc::ScopeObject, plugin::{Builder as PluginBuilder, TauriPlugin}, utils::{acl::Value, config::FsScope}, - AppHandle, DragDropEvent, Manager, RunEvent, Runtime, WindowEvent, }; #[cfg(target_os = "android")] diff --git a/plugins/fs/src/watcher.rs b/plugins/fs/src/watcher.rs index 68f6a8019..fbe1aa55e 100644 --- a/plugins/fs/src/watcher.rs +++ b/plugins/fs/src/watcher.rs @@ -3,20 +3,20 @@ // SPDX-License-Identifier: MIT use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher}; -use notify_debouncer_full::{new_debouncer, DebouncedEvent, Debouncer, RecommendedCache}; +use notify_debouncer_full::{DebouncedEvent, Debouncer, RecommendedCache, new_debouncer}; use serde::Deserialize; use tauri::{ + Manager, Resource, ResourceId, Runtime, Webview, ipc::{Channel, CommandScope, GlobalScope}, path::BaseDirectory, - Manager, Resource, ResourceId, Runtime, Webview, }; use std::time::Duration; use crate::{ - commands::{resolve_path, CommandResult}, - scope::Entry, SafeFilePath, + commands::{CommandResult, resolve_path}, + scope::Entry, }; #[allow(unused)] diff --git a/plugins/geolocation/src/commands.rs b/plugins/geolocation/src/commands.rs index d2cae848f..8da077850 100644 --- a/plugins/geolocation/src/commands.rs +++ b/plugins/geolocation/src/commands.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use tauri::{command, ipc::Channel, AppHandle, Runtime}; +use tauri::{AppHandle, Runtime, command, ipc::Channel}; use crate::{GeolocationExt, PermissionStatus, PermissionType, Position, PositionOptions, Result}; diff --git a/plugins/geolocation/src/desktop.rs b/plugins/geolocation/src/desktop.rs index 3ca41db5f..70b288033 100644 --- a/plugins/geolocation/src/desktop.rs +++ b/plugins/geolocation/src/desktop.rs @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{de::DeserializeOwned, Serialize}; +use serde::{Serialize, de::DeserializeOwned}; use tauri::{ + AppHandle, Runtime, ipc::{Channel, InvokeResponseBody}, plugin::PluginApi, - AppHandle, Runtime, }; use crate::models::*; diff --git a/plugins/geolocation/src/error.rs b/plugins/geolocation/src/error.rs index 1c4f69517..c8e959458 100644 --- a/plugins/geolocation/src/error.rs +++ b/plugins/geolocation/src/error.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{ser::Serializer, Serialize}; +use serde::{Serialize, ser::Serializer}; /// Alias for the result type returned by the geolocation APIs. pub type Result = std::result::Result; diff --git a/plugins/geolocation/src/lib.rs b/plugins/geolocation/src/lib.rs index 2c87c13f1..2c70a04dd 100644 --- a/plugins/geolocation/src/lib.rs +++ b/plugins/geolocation/src/lib.rs @@ -9,8 +9,8 @@ //! - **specta**: Add support for [`specta::specta`](https://docs.rs/specta/2.0.0-rc.25/specta/attr.specta.html) on structs like [`PermissionStatus`], [`PositionOptions`]. use tauri::{ - plugin::{Builder, TauriPlugin}, Manager, Runtime, + plugin::{Builder, TauriPlugin}, }; pub use models::*; diff --git a/plugins/geolocation/src/mobile.rs b/plugins/geolocation/src/mobile.rs index 4de9676a9..9e1262dd6 100644 --- a/plugins/geolocation/src/mobile.rs +++ b/plugins/geolocation/src/mobile.rs @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{de::DeserializeOwned, Serialize}; +use serde::{Serialize, de::DeserializeOwned}; use tauri::{ + AppHandle, Runtime, ipc::{Channel, InvokeResponseBody}, plugin::{PluginApi, PluginHandle}, - AppHandle, Runtime, }; use crate::models::*; diff --git a/plugins/global-shortcut/src/lib.rs b/plugins/global-shortcut/src/lib.rs index 19a4fa121..f65c1de1a 100644 --- a/plugins/global-shortcut/src/lib.rs +++ b/plugins/global-shortcut/src/lib.rs @@ -22,14 +22,14 @@ use std::{ use global_hotkey::GlobalHotKeyEvent; pub use global_hotkey::{ - hotkey::{Code, HotKey as Shortcut, Modifiers}, GlobalHotKeyEvent as ShortcutEvent, HotKeyState as ShortcutState, + hotkey::{Code, HotKey as Shortcut, Modifiers}, }; use serde::Serialize; use tauri::{ + AppHandle, Manager, Runtime, State, ipc::Channel, plugin::{Builder as PluginBuilder, TauriPlugin}, - AppHandle, Manager, Runtime, State, }; mod error; diff --git a/plugins/haptics/src/commands.rs b/plugins/haptics/src/commands.rs index 76f097c09..f91313b2a 100644 --- a/plugins/haptics/src/commands.rs +++ b/plugins/haptics/src/commands.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use tauri::{command, AppHandle, Runtime}; +use tauri::{AppHandle, Runtime, command}; use crate::{HapticsExt, ImpactFeedbackStyle, NotificationFeedbackType, Result}; diff --git a/plugins/haptics/src/desktop.rs b/plugins/haptics/src/desktop.rs index d036eddad..6011a606c 100644 --- a/plugins/haptics/src/desktop.rs +++ b/plugins/haptics/src/desktop.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use serde::de::DeserializeOwned; -use tauri::{plugin::PluginApi, AppHandle, Runtime}; +use tauri::{AppHandle, Runtime, plugin::PluginApi}; use crate::models::*; diff --git a/plugins/haptics/src/error.rs b/plugins/haptics/src/error.rs index 3a24755e8..faed672af 100644 --- a/plugins/haptics/src/error.rs +++ b/plugins/haptics/src/error.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{ser::Serializer, Serialize}; +use serde::{Serialize, ser::Serializer}; /// Alias for a [`std::result::Result`] with the error type [`Error`]. pub type Result = std::result::Result; diff --git a/plugins/haptics/src/lib.rs b/plugins/haptics/src/lib.rs index 7984bebb0..417343ac6 100644 --- a/plugins/haptics/src/lib.rs +++ b/plugins/haptics/src/lib.rs @@ -9,8 +9,8 @@ //! - **specta**: Add support for [`specta::specta`](https://docs.rs/specta/2.0.0-rc.25/specta/attr.specta.html) on structs like [`ImpactFeedbackStyle`], [`NotificationFeedbackType`]. use tauri::{ - plugin::{Builder, TauriPlugin}, Manager, Runtime, + plugin::{Builder, TauriPlugin}, }; pub use models::*; diff --git a/plugins/haptics/src/mobile.rs b/plugins/haptics/src/mobile.rs index 42ae2459a..e3446eb46 100644 --- a/plugins/haptics/src/mobile.rs +++ b/plugins/haptics/src/mobile.rs @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{de::DeserializeOwned, Serialize}; +use serde::{Serialize, de::DeserializeOwned}; use tauri::{ - plugin::{PluginApi, PluginHandle}, AppHandle, Runtime, + plugin::{PluginApi, PluginHandle}, }; use crate::models::*; diff --git a/plugins/http/src/commands.rs b/plugins/http/src/commands.rs index 4387bae30..e6c4d48db 100644 --- a/plugins/http/src/commands.rs +++ b/plugins/http/src/commands.rs @@ -4,20 +4,20 @@ use std::{future::Future, pin::Pin, str::FromStr, sync::Arc, time::Duration}; -use http::{header, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; -use reqwest::{redirect::Policy, NoProxy}; +use http::{HeaderMap, HeaderName, HeaderValue, Method, StatusCode, header}; +use reqwest::{NoProxy, redirect::Policy}; use serde::{Deserialize, Serialize}; use tauri::{ + Manager, ResourceId, ResourceTable, Runtime, State, Webview, async_runtime::Mutex, command, ipc::{CommandScope, GlobalScope}, - Manager, ResourceId, ResourceTable, Runtime, State, Webview, }; -use tokio::sync::oneshot::{channel, Receiver, Sender}; +use tokio::sync::oneshot::{Receiver, Sender, channel}; use crate::{ - scope::{Entry, Scope}, Error, Http, Result, + scope::{Entry, Scope}, }; const HTTP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),); @@ -257,8 +257,12 @@ pub async fn fetch( if is_unsafe_header(&name) { #[cfg(debug_assertions)] { - eprintln!("[\x1b[33mWARNING\x1b[0m] Skipping {name} header as it is a forbidden header per fetch spec https://fetch.spec.whatwg.org/#terminology-headers"); - eprintln!("[\x1b[33mWARNING\x1b[0m] if keeping the header is a desired behavior, you can enable `unsafe-headers` feature flag in your Cargo.toml"); + eprintln!( + "[\x1b[33mWARNING\x1b[0m] Skipping {name} header as it is a forbidden header per fetch spec https://fetch.spec.whatwg.org/#terminology-headers" + ); + eprintln!( + "[\x1b[33mWARNING\x1b[0m] if keeping the header is a desired behavior, you can enable `unsafe-headers` feature flag in your Cargo.toml" + ); } continue; } @@ -294,7 +298,9 @@ pub async fn fetch( { #[cfg(debug_assertions)] { - eprintln!("[\x1b[33mWARNING\x1b[0m] using dangerous settings requires `dangerous-settings` feature flag in your Cargo.toml"); + eprintln!( + "[\x1b[33mWARNING\x1b[0m] using dangerous settings requires `dangerous-settings` feature flag in your Cargo.toml" + ); } let _ = danger_config; return Err(Error::DangerousSettings); @@ -342,8 +348,8 @@ pub async fn fetch( } // ensure we have an Origin header set - if cfg!(not(feature = "unsafe-headers")) || !headers.contains_key(header::ORIGIN) { - if let Ok(url) = webview.url() { + if (cfg!(not(feature = "unsafe-headers")) || !headers.contains_key(header::ORIGIN)) + && let Ok(url) = webview.url() { // The url crate returns OpaqueOrigin for tauri://localhost which serializes to "null" let origin = if url.scheme() == "tauri" { "tauri://localhost".to_string() @@ -352,7 +358,6 @@ pub async fn fetch( }; headers.append(header::ORIGIN, HeaderValue::from_str(&origin)?); } - } // In case empty origin is passed, remove it. Some services do not like Origin header // so this way we can remove it in explicit way. The default behaviour is still to set it @@ -593,8 +598,10 @@ mod tests { Some(location) => format!( "HTTP/1.1 302 Found\r\nLocation: {location}\r\nContent-Length: 0\r\nConnection: close\r\n\r\n" ), - None => "HTTP/1.1 200 OK\r\nContent-Length: 6\r\nConnection: close\r\n\r\nsecret" - .to_string(), + None => { + "HTTP/1.1 200 OK\r\nContent-Length: 6\r\nConnection: close\r\n\r\nsecret" + .to_string() + } }; let _ = stream.write_all(response.as_bytes()); diff --git a/plugins/http/src/lib.rs b/plugins/http/src/lib.rs index 6444ef99e..e6db850f0 100644 --- a/plugins/http/src/lib.rs +++ b/plugins/http/src/lib.rs @@ -61,8 +61,8 @@ pub use reqwest; use tauri::{ - plugin::{Builder, TauriPlugin}, Manager, Runtime, + plugin::{Builder, TauriPlugin}, }; pub use config::Config; diff --git a/plugins/http/src/reqwest_cookie_store.rs b/plugins/http/src/reqwest_cookie_store.rs index 0b71902bd..ef389807b 100644 --- a/plugins/http/src/reqwest_cookie_store.rs +++ b/plugins/http/src/reqwest_cookie_store.rs @@ -6,7 +6,7 @@ use std::{ path::PathBuf, - sync::{mpsc::Receiver, Mutex}, + sync::{Mutex, mpsc::Receiver}, }; use cookie_store::{CookieStore, RawCookie, RawCookieParseError}; diff --git a/plugins/http/src/scope.rs b/plugins/http/src/scope.rs index a7745c2cd..c39540e75 100644 --- a/plugins/http/src/scope.rs +++ b/plugins/http/src/scope.rs @@ -154,11 +154,13 @@ mod tests { assert!(scope.is_allowed(&"http://localhost:8080/file.png".parse().unwrap())); assert!(scope.is_allowed(&"http://localhost:8080/file.png#head".parse().unwrap())); assert!(scope.is_allowed(&"http://localhost:8080/assets/file.png".parse().unwrap())); - assert!(scope.is_allowed( - &"http://localhost:8080/assets/file.png?width=100&height=200" - .parse() - .unwrap() - )); + assert!( + scope.is_allowed( + &"http://localhost:8080/assets/file.png?width=100&height=200" + .parse() + .unwrap() + ) + ); assert!(!scope.is_allowed(&"http://localhost:8080/file.jpeg".parse().unwrap())); } @@ -172,11 +174,13 @@ mod tests { assert!(scope.is_allowed(&"http://something.else#tauri".parse().unwrap())); assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap())); assert!(scope.is_allowed(&"http://something.else?rel=tauri".parse().unwrap())); - assert!(scope.is_allowed( - &"http://something.else/path/to/file.mp4?start=500" - .parse() - .unwrap() - )); + assert!( + scope.is_allowed( + &"http://something.else/path/to/file.mp4?start=500" + .parse() + .unwrap() + ) + ); assert!(!scope.is_allowed(&"https://something.else".parse().unwrap())); diff --git a/plugins/localhost/src/lib.rs b/plugins/localhost/src/lib.rs index aba034b94..5641f589b 100644 --- a/plugins/localhost/src/lib.rs +++ b/plugins/localhost/src/lib.rs @@ -15,8 +15,8 @@ use std::collections::HashMap; use http::Uri; use tauri::{ - plugin::{Builder as PluginBuilder, TauriPlugin}, Runtime, + plugin::{Builder as PluginBuilder, TauriPlugin}, }; use tiny_http::{Header, Response as HttpResponse, Server}; diff --git a/plugins/log/src/lib.rs b/plugins/log/src/lib.rs index 18e872758..a6740efd4 100644 --- a/plugins/log/src/lib.rs +++ b/plugins/log/src/lib.rs @@ -27,12 +27,12 @@ use std::{ iter::FromIterator, path::{Path, PathBuf}, }; -use tauri::{ - plugin::{self, TauriPlugin}, - Manager, Runtime, -}; use tauri::{AppHandle, Emitter}; -use time::{macros::format_description, OffsetDateTime}; +use tauri::{ + Manager, Runtime, + plugin::{self, TauriPlugin}, +}; +use time::{OffsetDateTime, macros::format_description}; pub use fern; pub use log; diff --git a/plugins/nfc/src/error.rs b/plugins/nfc/src/error.rs index 75d21ea92..51811c6da 100644 --- a/plugins/nfc/src/error.rs +++ b/plugins/nfc/src/error.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{ser::Serializer, Serialize}; +use serde::{Serialize, ser::Serializer}; /// Alias for a [`std::result::Result`] with the error type [`Error`]. pub type Result = std::result::Result; diff --git a/plugins/nfc/src/lib.rs b/plugins/nfc/src/lib.rs index 0396b7733..1bfb1b3a7 100644 --- a/plugins/nfc/src/lib.rs +++ b/plugins/nfc/src/lib.rs @@ -14,8 +14,8 @@ use serde::{Deserialize, Serialize}; use tauri::{ - plugin::{Builder, PluginHandle, TauriPlugin}, Manager, Runtime, + plugin::{Builder, PluginHandle, TauriPlugin}, }; pub use models::*; diff --git a/plugins/notification/src/commands.rs b/plugins/notification/src/commands.rs index 99b96c5b0..c38a842e2 100644 --- a/plugins/notification/src/commands.rs +++ b/plugins/notification/src/commands.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use tauri::{command, plugin::PermissionState, AppHandle, Runtime, State}; +use tauri::{AppHandle, Runtime, State, command, plugin::PermissionState}; use crate::{Notification, NotificationData, Result}; diff --git a/plugins/notification/src/desktop.rs b/plugins/notification/src/desktop.rs index cd8bddfb9..b86b74f2a 100644 --- a/plugins/notification/src/desktop.rs +++ b/plugins/notification/src/desktop.rs @@ -4,8 +4,8 @@ use serde::de::DeserializeOwned; use tauri::{ - plugin::{PermissionState, PluginApi}, AppHandle, Runtime, + plugin::{PermissionState, PluginApi}, }; use crate::NotificationBuilder; diff --git a/plugins/notification/src/error.rs b/plugins/notification/src/error.rs index f43da5823..ff5305bef 100644 --- a/plugins/notification/src/error.rs +++ b/plugins/notification/src/error.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{ser::Serializer, Serialize}; +use serde::{Serialize, ser::Serializer}; /// Alias for a [`std::result::Result`] with the error type set to [`Error`]. pub type Result = std::result::Result; diff --git a/plugins/notification/src/lib.rs b/plugins/notification/src/lib.rs index 9fd74406a..61042aeec 100644 --- a/plugins/notification/src/lib.rs +++ b/plugins/notification/src/lib.rs @@ -14,13 +14,13 @@ )] use serde::Serialize; -#[cfg(mobile)] -use tauri::plugin::PluginHandle; #[cfg(desktop)] use tauri::AppHandle; +#[cfg(mobile)] +use tauri::plugin::PluginHandle; use tauri::{ - plugin::{Builder, TauriPlugin}, Manager, Runtime, + plugin::{Builder, TauriPlugin}, }; pub use models::*; diff --git a/plugins/notification/src/mobile.rs b/plugins/notification/src/mobile.rs index 250532d4a..722518503 100644 --- a/plugins/notification/src/mobile.rs +++ b/plugins/notification/src/mobile.rs @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{de::DeserializeOwned, Deserialize}; +use serde::{Deserialize, de::DeserializeOwned}; use tauri::{ - plugin::{PermissionState, PluginApi, PluginHandle}, AppHandle, Runtime, + plugin::{PermissionState, PluginApi, PluginHandle}, }; use crate::models::*; diff --git a/plugins/notification/src/models.rs b/plugins/notification/src/models.rs index ce5993a0f..b146dcb89 100644 --- a/plugins/notification/src/models.rs +++ b/plugins/notification/src/models.rs @@ -4,7 +4,7 @@ use std::{collections::HashMap, fmt::Display}; -use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error as DeError}; use url::Url; @@ -188,11 +188,11 @@ pub enum Schedule { // custom ISO-8601 serialization that does not use 6 digits for years. mod iso8601 { - use serde::{ser::Error as _, Serialize, Serializer}; + use serde::{Serialize, Serializer, ser::Error as _}; use time::{ - format_description::well_known::iso8601::{Config, EncodedConfig}, - format_description::well_known::Iso8601, OffsetDateTime, + format_description::well_known::Iso8601, + format_description::well_known::iso8601::{Config, EncodedConfig}, }; const SERDE_CONFIG: EncodedConfig = Config::DEFAULT.encode(); diff --git a/plugins/opener/src/commands.rs b/plugins/opener/src/commands.rs index e22b41d41..af66d9726 100644 --- a/plugins/opener/src/commands.rs +++ b/plugins/opener/src/commands.rs @@ -5,11 +5,11 @@ use std::path::{Path, PathBuf}; use tauri::{ - ipc::{CommandScope, GlobalScope}, AppHandle, Runtime, + ipc::{CommandScope, GlobalScope}, }; -use crate::{scope::Scope, Error, OpenerExt}; +use crate::{Error, OpenerExt, scope::Scope}; #[tauri::command] pub async fn open_url( diff --git a/plugins/opener/src/lib.rs b/plugins/opener/src/lib.rs index 13f6efb85..5354c5fd3 100644 --- a/plugins/opener/src/lib.rs +++ b/plugins/opener/src/lib.rs @@ -13,7 +13,7 @@ use std::path::Path; -use tauri::{plugin::TauriPlugin, Manager, Runtime}; +use tauri::{Manager, Runtime, plugin::TauriPlugin}; #[cfg(mobile)] use tauri::plugin::PluginHandle; diff --git a/plugins/opener/src/reveal_item_in_dir.rs b/plugins/opener/src/reveal_item_in_dir.rs index 9578a2823..1b593cf6b 100644 --- a/plugins/opener/src/reveal_item_in_dir.rs +++ b/plugins/opener/src/reveal_item_in_dir.rs @@ -93,18 +93,18 @@ mod imp { use windows::Win32::UI::Shell::Common::ITEMIDLIST; use windows::{ - core::{w, HSTRING, PCWSTR}, Win32::{ Foundation::ERROR_FILE_NOT_FOUND, System::Com::CoInitialize, UI::{ Shell::{ - ILCreateFromPathW, ILFree, SHOpenFolderAndSelectItems, ShellExecuteExW, - SHELLEXECUTEINFOW, + ILCreateFromPathW, ILFree, SHELLEXECUTEINFOW, SHOpenFolderAndSelectItems, + ShellExecuteExW, }, WindowsAndMessaging::SW_SHOWNORMAL, }, }, + core::{HSTRING, PCWSTR, w}, }; pub fn reveal_items_in_dir(paths: &[PathBuf]) -> crate::Result<()> { diff --git a/plugins/opener/src/scope.rs b/plugins/opener/src/scope.rs index 275913d1b..393928b79 100644 --- a/plugins/opener/src/scope.rs +++ b/plugins/opener/src/scope.rs @@ -8,9 +8,9 @@ use std::{ sync::Arc, }; -use tauri::{ipc::ScopeObject, utils::acl::Value, AppHandle, Manager, Runtime}; +use tauri::{AppHandle, Manager, Runtime, ipc::ScopeObject, utils::acl::Value}; -use crate::{scope_entry::EntryRaw, Error}; +use crate::{Error, scope_entry::EntryRaw}; pub use crate::scope_entry::Application; diff --git a/plugins/opener/src/windows_shell_path.rs b/plugins/opener/src/windows_shell_path.rs index 8715641db..f3cb61529 100644 --- a/plugins/opener/src/windows_shell_path.rs +++ b/plugins/opener/src/windows_shell_path.rs @@ -10,7 +10,7 @@ use std::{ path::{Component, Path, PathBuf, Prefix, PrefixComponent}, }; -use windows::{core::HSTRING, Win32::Storage::FileSystem::GetFullPathNameW}; +use windows::{Win32::Storage::FileSystem::GetFullPathNameW, core::HSTRING}; pub fn absolute_and_check_exists(path: &Path) -> io::Result { let path = absolute(path)?; diff --git a/plugins/os/src/lib.rs b/plugins/os/src/lib.rs index 853dbdf69..12350c4de 100644 --- a/plugins/os/src/lib.rs +++ b/plugins/os/src/lib.rs @@ -12,10 +12,10 @@ use std::fmt::Display; pub use os_info::Version; -use serialize_to_javascript::{default_template, DefaultTemplate, Template}; +use serialize_to_javascript::{DefaultTemplate, Template, default_template}; use tauri::{ - plugin::{Builder, TauriPlugin}, Runtime, + plugin::{Builder, TauriPlugin}, }; mod commands; diff --git a/plugins/persisted-scope/src/lib.rs b/plugins/persisted-scope/src/lib.rs index 96331651e..57f84979d 100644 --- a/plugins/persisted-scope/src/lib.rs +++ b/plugins/persisted-scope/src/lib.rs @@ -17,13 +17,13 @@ use aho_corasick::AhoCorasick; use serde::{Deserialize, Serialize}; use tauri::{ - plugin::{Builder, TauriPlugin}, Manager, Runtime, + plugin::{Builder, TauriPlugin}, }; use tauri_plugin_fs::FsExt; use std::{ - fs::{create_dir_all, File}, + fs::{File, create_dir_all}, io::Write, path::Path, }; @@ -198,8 +198,8 @@ pub fn init() -> TauriPlugin { // We will still save some semi-broken values because the scope events are quite spammy and we don't want to reduce runtime performance any further. let ac = AhoCorasick::new(PATTERNS).unwrap(/* This should be impossible to fail since we're using a small static input */); - if let Some(fs_scope) = &fs_scope { - if fs_scope_state_path.exists() { + if let Some(fs_scope) = &fs_scope + && fs_scope_state_path.exists() { let scope: Scope = std::fs::read(&fs_scope_state_path) .map_err(Error::from) .and_then(|scope| bincode::deserialize(&scope).map_err(Into::into)) @@ -218,7 +218,6 @@ pub fn init() -> TauriPlugin { // This is needed to fix broken .peristed-scope files in case the app doesn't update the scope itself. save_scopes(fs_scope, &app_dir, &fs_scope_state_path); } - } #[cfg(feature = "protocol-asset")] if asset_scope_state_path.exists() { diff --git a/plugins/positioner/src/lib.rs b/plugins/positioner/src/lib.rs index fd5e82638..a437ffe36 100644 --- a/plugins/positioner/src/lib.rs +++ b/plugins/positioner/src/lib.rs @@ -21,12 +21,12 @@ mod ext; pub use ext::*; use tauri::{ - plugin::{self, TauriPlugin}, Result, Runtime, + plugin::{self, TauriPlugin}, }; #[cfg(feature = "tray-icon")] -use tauri::{tray::TrayIconEvent, AppHandle, Manager, PhysicalPosition, PhysicalSize}; +use tauri::{AppHandle, Manager, PhysicalPosition, PhysicalSize, tray::TrayIconEvent}; #[cfg(feature = "tray-icon")] struct Tray(std::sync::Mutex, PhysicalSize)>>); diff --git a/plugins/process/src/lib.rs b/plugins/process/src/lib.rs index d7f05f481..f122ef0b3 100644 --- a/plugins/process/src/lib.rs +++ b/plugins/process/src/lib.rs @@ -10,8 +10,8 @@ )] use tauri::{ - plugin::{Builder, TauriPlugin}, Runtime, + plugin::{Builder, TauriPlugin}, }; mod commands; diff --git a/plugins/shell/src/commands.rs b/plugins/shell/src/commands.rs index 0facce719..2d1a73edf 100644 --- a/plugins/shell/src/commands.rs +++ b/plugins/shell/src/commands.rs @@ -7,16 +7,16 @@ use std::{collections::HashMap, future::Future, path::PathBuf, pin::Pin, string: use encoding_rs::Encoding; use serde::{Deserialize, Serialize}; use tauri::{ - ipc::{Channel, CommandScope, GlobalScope}, Manager, Runtime, State, Window, + ipc::{Channel, CommandScope, GlobalScope}, }; #[allow(deprecated)] use crate::open::Program; use crate::{ + Shell, process::{CommandEvent, TerminatedPayload}, scope::ExecuteArgs, - Shell, }; type ChildId = u32; diff --git a/plugins/shell/src/lib.rs b/plugins/shell/src/lib.rs index 2615b12f4..dd5967456 100644 --- a/plugins/shell/src/lib.rs +++ b/plugins/shell/src/lib.rs @@ -19,8 +19,8 @@ use std::{ use process::{Command, CommandChild}; use regex::Regex; use tauri::{ - plugin::{Builder, TauriPlugin}, AppHandle, Manager, RunEvent, Runtime, + plugin::{Builder, TauriPlugin}, }; mod commands; diff --git a/plugins/shell/src/process/mod.rs b/plugins/shell/src/process/mod.rs index 7a1c2db24..45e165e61 100644 --- a/plugins/shell/src/process/mod.rs +++ b/plugins/shell/src/process/mod.rs @@ -20,10 +20,10 @@ use std::os::windows::process::CommandExt; const CREATE_NO_WINDOW: u32 = 0x0800_0000; const NEWLINE_BYTE: u8 = b'\n'; -use tauri::async_runtime::{block_on as block_on_task, channel, Receiver, Sender}; +use tauri::async_runtime::{Receiver, Sender, block_on as block_on_task, channel}; pub use encoding_rs::Encoding; -use os_pipe::{pipe, PipeReader, PipeWriter}; +use os_pipe::{PipeReader, PipeWriter, pipe}; use serde::Serialize; use shared_child::SharedChild; use tauri::utils::platform; diff --git a/plugins/shell/src/scope.rs b/plugins/shell/src/scope.rs index 35fdeaffb..cbc096c43 100644 --- a/plugins/shell/src/scope.rs +++ b/plugins/shell/src/scope.rs @@ -9,8 +9,8 @@ use crate::open::Program; use crate::process::Command; use regex::Regex; -use tauri::ipc::ScopeObject; use tauri::Manager; +use tauri::ipc::ScopeObject; /// Allowed representation of `Execute` command arguments. #[derive(Debug, Clone, serde::Deserialize)] @@ -162,8 +162,8 @@ pub enum Error { /// The sidecar program validated but failed to find the sidecar path. #[error( - "The scoped sidecar command was validated, but failed to create the path to the command: {0}" - )] + "The scoped sidecar command was validated, but failed to create the path to the command: {0}" + )] Sidecar(String), /// The named command was not found in the scoped config. @@ -172,12 +172,14 @@ pub enum Error { /// A command variable has no value set in the arguments. #[error( - "Scoped command argument at position {0} must match regex validation {1} but it was not found" - )] + "Scoped command argument at position {0} must match regex validation {1} but it was not found" + )] MissingVar(usize, String), /// At least one argument did not pass input validation. - #[error("Scoped command argument at position {index} was found, but failed regex validation {validation}")] + #[error( + "Scoped command argument at position {index} was found, but failed regex validation {validation}" + )] Validation { /// Index of the variable. index: usize, @@ -214,7 +216,9 @@ impl OpenScope { }); } } else { - log::warn!("open() command called but the plugin configuration denies calls from JavaScript; set `tauri.conf.json > plugins > shell > open` to true or a validation regex string"); + log::warn!( + "open() command called but the plugin configuration denies calls from JavaScript; set `tauri.conf.json > plugins > shell > open` to true or a validation regex string" + ); return Err(Error::Validation { index: 0, validation: "tauri^".to_string(), // purposefully impossible regex diff --git a/plugins/shell/src/scope_entry.rs b/plugins/shell/src/scope_entry.rs index 8a70fff79..61eff93cc 100644 --- a/plugins/shell/src/scope_entry.rs +++ b/plugins/shell/src/scope_entry.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use serde::{de::Error as DeError, Deserialize, Deserializer}; +use serde::{Deserialize, Deserializer, de::Error as DeError}; use std::path::PathBuf; diff --git a/plugins/single-instance/examples/vanilla/src-tauri/Cargo.toml b/plugins/single-instance/examples/vanilla/src-tauri/Cargo.toml index 59624cbc4..816aac04b 100644 --- a/plugins/single-instance/examples/vanilla/src-tauri/Cargo.toml +++ b/plugins/single-instance/examples/vanilla/src-tauri/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" description = "A Tauri App" authors = ["You"] repository = "" -edition = "2021" +edition = "2024" rust-version = "1.90" [dependencies] diff --git a/plugins/single-instance/src/lib.rs b/plugins/single-instance/src/lib.rs index 9a254a517..eaf358486 100644 --- a/plugins/single-instance/src/lib.rs +++ b/plugins/single-instance/src/lib.rs @@ -15,7 +15,7 @@ )] #![cfg(not(any(target_os = "android", target_os = "ios")))] -use tauri::{plugin::TauriPlugin, AppHandle, Manager, Runtime}; +use tauri::{AppHandle, Manager, Runtime, plugin::TauriPlugin}; #[cfg(target_os = "windows")] #[path = "platform_impl/windows.rs"] diff --git a/plugins/single-instance/src/platform_impl/linux.rs b/plugins/single-instance/src/platform_impl/linux.rs index 892baee7f..0cc7e8371 100644 --- a/plugins/single-instance/src/platform_impl/linux.rs +++ b/plugins/single-instance/src/platform_impl/linux.rs @@ -7,8 +7,8 @@ use crate::semver_compat::semver_compat_string; use crate::SingleInstanceCallback; use tauri::{ - plugin::{self, TauriPlugin}, AppHandle, Manager, RunEvent, Runtime, + plugin::{self, TauriPlugin}, }; use zbus::{blocking::Connection, interface, names::WellKnownName}; @@ -101,12 +101,11 @@ pub fn init( } pub fn destroy>(manager: &M) { - if let Some(connection) = manager.try_state::() { - if let Some(dbus_name) = manager + if let Some(connection) = manager.try_state::() + && let Some(dbus_name) = manager .try_state::() .and_then(|name| WellKnownName::try_from(name.0.clone()).ok()) { let _ = connection.0.release_name(dbus_name); } - } } diff --git a/plugins/single-instance/src/platform_impl/macos.rs b/plugins/single-instance/src/platform_impl/macos.rs index bd2c74a7e..ccd66f360 100644 --- a/plugins/single-instance/src/platform_impl/macos.rs +++ b/plugins/single-instance/src/platform_impl/macos.rs @@ -8,12 +8,12 @@ use std::{ path::PathBuf, }; +use crate::SingleInstanceCallback; #[cfg(feature = "semver")] use crate::semver_compat::semver_compat_string; -use crate::SingleInstanceCallback; use tauri::{ - plugin::{self, TauriPlugin}, AppHandle, Config, Manager, RunEvent, Runtime, + plugin::{self, TauriPlugin}, }; use tokio::io::AsyncReadExt; diff --git a/plugins/single-instance/src/platform_impl/windows.rs b/plugins/single-instance/src/platform_impl/windows.rs index 196f7851f..075845c59 100644 --- a/plugins/single-instance/src/platform_impl/windows.rs +++ b/plugins/single-instance/src/platform_impl/windows.rs @@ -8,20 +8,20 @@ use crate::semver_compat::semver_compat_string; use crate::SingleInstanceCallback; use std::ffi::CStr; use tauri::{ - plugin::{self, TauriPlugin}, AppHandle, Manager, RunEvent, Runtime, + plugin::{self, TauriPlugin}, }; use windows_sys::Win32::{ - Foundation::{CloseHandle, GetLastError, ERROR_ALREADY_EXISTS, HWND, LPARAM, LRESULT, WPARAM}, + Foundation::{CloseHandle, ERROR_ALREADY_EXISTS, GetLastError, HWND, LPARAM, LRESULT, WPARAM}, System::{ DataExchange::COPYDATASTRUCT, LibraryLoader::GetModuleHandleW, Threading::{CreateMutexW, ReleaseMutex}, }, UI::WindowsAndMessaging::{ - self as w32wm, AllowSetForegroundWindow, CreateWindowExW, DefWindowProcW, DestroyWindow, - FindWindowW, GetWindowThreadProcessId, RegisterClassExW, SendMessageW, CREATESTRUCTW, - GWLP_USERDATA, GWL_STYLE, WINDOW_LONG_PTR_INDEX, WM_COPYDATA, WM_CREATE, WM_DESTROY, + self as w32wm, AllowSetForegroundWindow, CREATESTRUCTW, CreateWindowExW, DefWindowProcW, + DestroyWindow, FindWindowW, GWL_STYLE, GWLP_USERDATA, GetWindowThreadProcessId, + RegisterClassExW, SendMessageW, WINDOW_LONG_PTR_INDEX, WM_COPYDATA, WM_CREATE, WM_DESTROY, WNDCLASSEXW, WS_EX_LAYERED, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP, WS_VISIBLE, }, diff --git a/plugins/sql/src/commands.rs b/plugins/sql/src/commands.rs index 760d00b2d..89b89bea3 100644 --- a/plugins/sql/src/commands.rs +++ b/plugins/sql/src/commands.rs @@ -5,7 +5,7 @@ use indexmap::IndexMap; use serde_json::Value as JsonValue; use sqlx::migrate::Migrator; -use tauri::{command, AppHandle, Runtime, State}; +use tauri::{AppHandle, Runtime, State, command}; use crate::{DbInstances, DbPool, Error, LastInsertId, Migrations}; diff --git a/plugins/sql/src/decode/mysql.rs b/plugins/sql/src/decode/mysql.rs index 53fd20c7c..c8eaeffbd 100644 --- a/plugins/sql/src/decode/mysql.rs +++ b/plugins/sql/src/decode/mysql.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use serde_json::Value as JsonValue; -use sqlx::{mysql::MySqlValueRef, TypeInfo, Value, ValueRef}; +use sqlx::{TypeInfo, Value, ValueRef, mysql::MySqlValueRef}; use time::{Date, OffsetDateTime, PrimitiveDateTime, Time}; use crate::Error; diff --git a/plugins/sql/src/decode/postgres.rs b/plugins/sql/src/decode/postgres.rs index 4af9b713d..083322df1 100644 --- a/plugins/sql/src/decode/postgres.rs +++ b/plugins/sql/src/decode/postgres.rs @@ -4,7 +4,7 @@ use rust_decimal::prelude::ToPrimitive; use serde_json::Value as JsonValue; -use sqlx::{postgres::PgValueRef, TypeInfo, Value, ValueRef}; +use sqlx::{TypeInfo, Value, ValueRef, postgres::PgValueRef}; use time::{Date, OffsetDateTime, PrimitiveDateTime, Time}; use uuid::Uuid; diff --git a/plugins/sql/src/decode/sqlite.rs b/plugins/sql/src/decode/sqlite.rs index 1f0808ae3..c310ac398 100644 --- a/plugins/sql/src/decode/sqlite.rs +++ b/plugins/sql/src/decode/sqlite.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use serde_json::Value as JsonValue; -use sqlx::{sqlite::SqliteValueRef, TypeInfo, Value, ValueRef}; +use sqlx::{TypeInfo, Value, ValueRef, sqlite::SqliteValueRef}; use time::{Date, PrimitiveDateTime, Time}; use crate::Error; diff --git a/plugins/sql/src/lib.rs b/plugins/sql/src/lib.rs index dca4928c5..20eee0337 100644 --- a/plugins/sql/src/lib.rs +++ b/plugins/sql/src/lib.rs @@ -33,8 +33,8 @@ use sqlx::{ migrate::{Migration as SqlxMigration, MigrationSource, MigrationType, Migrator}, }; use tauri::{ - plugin::{Builder as PluginBuilder, TauriPlugin}, Manager, RunEvent, Runtime, + plugin::{Builder as PluginBuilder, TauriPlugin}, }; use tokio::sync::{Mutex, RwLock}; @@ -158,7 +158,9 @@ impl Builder { /// connected to in that case. pub fn new() -> Self { #[cfg(not(any(feature = "sqlite", feature = "mysql", feature = "postgres")))] - eprintln!("No sql driver enabled. Please set at least one of the \"sqlite\", \"mysql\", \"postgres\" feature flags."); + eprintln!( + "No sql driver enabled. Please set at least one of the \"sqlite\", \"mysql\", \"postgres\" feature flags." + ); Self::default() } diff --git a/plugins/sql/src/wrapper.rs b/plugins/sql/src/wrapper.rs index f07a95e51..da0589433 100644 --- a/plugins/sql/src/wrapper.rs +++ b/plugins/sql/src/wrapper.rs @@ -8,7 +8,7 @@ use std::fs::create_dir_all; use indexmap::IndexMap; use serde_json::Value as JsonValue; #[cfg(any(feature = "sqlite", feature = "mysql", feature = "postgres"))] -use sqlx::{migrate::MigrateDatabase, Column, Executor, Pool, Row}; +use sqlx::{Column, Executor, Pool, Row, migrate::MigrateDatabase}; #[cfg(any(feature = "sqlite", feature = "mysql", feature = "postgres"))] use tauri::Manager; use tauri::{AppHandle, Runtime}; diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/Cargo.toml b/plugins/store/examples/AppSettingsManager/src-tauri/Cargo.toml index d005f10ef..d6023a7a8 100644 --- a/plugins/store/examples/AppSettingsManager/src-tauri/Cargo.toml +++ b/plugins/store/examples/AppSettingsManager/src-tauri/Cargo.toml @@ -5,7 +5,7 @@ description = "A Tauri App" authors = ["you"] license = "" repository = "" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/plugins/store/src/lib.rs b/plugins/store/src/lib.rs index 4a49dda01..3c472accf 100644 --- a/plugins/store/src/lib.rs +++ b/plugins/store/src/lib.rs @@ -18,10 +18,10 @@ use std::{ sync::{Arc, RwLock}, time::Duration, }; -pub use store::{resolve_store_path, DeserializeFn, SerializeFn, Store, StoreBuilder}; +pub use store::{DeserializeFn, SerializeFn, Store, StoreBuilder, resolve_store_path}; use tauri::{ - plugin::{self, TauriPlugin}, AppHandle, Manager, ResourceId, RunEvent, Runtime, State, + plugin::{self, TauriPlugin}, }; mod error; @@ -470,11 +470,10 @@ impl Builder { let collection = app_handle.state::(); let stores = collection.stores.read().unwrap(); for (path, rid) in stores.iter() { - if let Ok(store) = app_handle.resources_table().get::>(*rid) { - if let Err(err) = store.save() { + if let Ok(store) = app_handle.resources_table().get::>(*rid) + && let Err(err) = store.save() { tracing::error!("failed to save store {path:?} with error {err:?}"); } - } } } }) diff --git a/plugins/store/src/store.rs b/plugins/store/src/store.rs index b13a34ab4..42ac2cbf8 100644 --- a/plugins/store/src/store.rs +++ b/plugins/store/src/store.rs @@ -11,10 +11,10 @@ use std::{ sync::{Arc, Mutex}, time::Duration, }; -use tauri::{path::BaseDirectory, AppHandle, Emitter, Manager, Resource, ResourceId, Runtime}; +use tauri::{AppHandle, Emitter, Manager, Resource, ResourceId, Runtime, path::BaseDirectory}; use tokio::{ select, - sync::mpsc::{unbounded_channel, UnboundedSender}, + sync::mpsc::{UnboundedSender, unbounded_channel}, time::sleep, }; diff --git a/plugins/stronghold/src/kdf.rs b/plugins/stronghold/src/kdf.rs index f0d3aa8cb..1bc2c6297 100644 --- a/plugins/stronghold/src/kdf.rs +++ b/plugins/stronghold/src/kdf.rs @@ -45,8 +45,8 @@ fn create_or_get_salt(salt: &mut [u8], salt_path: &Path) { salt.clone_from_slice(&tmp); } else { // Generate new salt - let mut gen = ChaCha20Rng::from_os_rng(); - gen.fill_bytes(salt); + let mut rng = ChaCha20Rng::from_os_rng(); + rng.fill_bytes(salt); std::fs::write(salt_path, salt).expect("Failed to write salt for Stronghold") } } diff --git a/plugins/stronghold/src/lib.rs b/plugins/stronghold/src/lib.rs index 95ea71513..4c98b664c 100644 --- a/plugins/stronghold/src/lib.rs +++ b/plugins/stronghold/src/lib.rs @@ -23,18 +23,18 @@ use std::{ use crypto::keys::bip39; use iota_stronghold::{ + Client, Location, procedures::{ BIP39Generate, BIP39Recover, Curve, Ed25519Sign, KeyType as StrongholdKeyType, MnemonicLanguage, PublicKey, Slip10Derive, Slip10DeriveInput, Slip10Generate, StrongholdProcedure, }, - Client, Location, }; -use serde::{de::Visitor, Deserialize, Deserializer}; +use serde::{Deserialize, Deserializer, de::Visitor}; use stronghold::{Error, Result, Stronghold}; use tauri::{ - plugin::{Builder as PluginBuilder, TauriPlugin}, Manager, Runtime, State, + plugin::{Builder as PluginBuilder, TauriPlugin}, }; use zeroize::{Zeroize, Zeroizing}; @@ -270,12 +270,11 @@ async fn destroy( snapshot_path: PathBuf, ) -> Result<()> { let mut collection = collection.0.lock().unwrap(); - if let Some(stronghold) = collection.remove(&snapshot_path) { - if let Err(e) = stronghold.save() { + if let Some(stronghold) = collection.remove(&snapshot_path) + && let Err(e) = stronghold.save() { collection.insert(snapshot_path, stronghold); return Err(e); } - } Ok(()) } diff --git a/plugins/updater/src/commands.rs b/plugins/updater/src/commands.rs index 72684e6d8..9657a6997 100644 --- a/plugins/updater/src/commands.rs +++ b/plugins/updater/src/commands.rs @@ -6,7 +6,7 @@ use crate::{Result, Update, UpdaterExt}; use http::{HeaderMap, HeaderName, HeaderValue}; use serde::Serialize; -use tauri::{ipc::Channel, Manager, Resource, ResourceId, Runtime, Webview}; +use tauri::{Manager, Resource, ResourceId, Runtime, Webview, ipc::Channel}; use std::{str::FromStr, time::Duration}; use url::Url; diff --git a/plugins/updater/src/config.rs b/plugins/updater/src/config.rs index 9bd941ad5..56f01c97a 100644 --- a/plugins/updater/src/config.rs +++ b/plugins/updater/src/config.rs @@ -204,8 +204,12 @@ pub(crate) fn validate_endpoints( if url.scheme() != "https" { #[cfg(debug_assertions)] { - eprintln!("[\x1b[33mWARNING\x1b[0m] The updater endpoint \"{url}\" doesn't use `https` protocol. This is allowed in development but will fail in release builds."); - eprintln!("[\x1b[33mWARNING\x1b[0m] if this is a desired behavior, you can enable `dangerousInsecureTransportProtocol` in the plugin configuration"); + eprintln!( + "[\x1b[33mWARNING\x1b[0m] The updater endpoint \"{url}\" doesn't use `https` protocol. This is allowed in development but will fail in release builds." + ); + eprintln!( + "[\x1b[33mWARNING\x1b[0m] if this is a desired behavior, you can enable `dangerousInsecureTransportProtocol` in the plugin configuration" + ); } #[cfg(not(debug_assertions))] return Err(crate::Error::InsecureTransportProtocol); diff --git a/plugins/updater/src/error.rs b/plugins/updater/src/error.rs index 916220be7..6c7c21534 100644 --- a/plugins/updater/src/error.rs +++ b/plugins/updater/src/error.rs @@ -25,7 +25,9 @@ pub enum Error { #[error("Could not fetch a valid release JSON from the remote")] ReleaseNotFound, /// Unsupported app architecture. - #[error("Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`.")] + #[error( + "Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`." + )] UnsupportedArch, /// Operating system is not supported. #[error("Unsupported OS, expected one of `linux`, `darwin` or `windows`.")] @@ -43,9 +45,7 @@ pub enum Error { #[error("the platform `{0}` was not found in the response `platforms` object")] TargetNotFound(String), /// Neither the platform nor the fallback platform was found in the updater JSON response. - #[error( - "None of the fallback platforms `{0:?}` were found in the response `platforms` object" - )] + #[error("None of the fallback platforms `{0:?}` were found in the response `platforms` object")] TargetsNotFound(Vec), /// Download failed #[error("`{0}`")] @@ -57,7 +57,9 @@ pub enum Error { #[error(transparent)] Base64(#[from] base64::DecodeError), /// UTF8 Errors in signature. - #[error("The signature {0} could not be decoded, please check if it is a valid base64 string. The signature must be the contents of the `.sig` file generated by the Tauri bundler, as a string.")] + #[error( + "The signature {0} could not be decoded, please check if it is a valid base64 string. The signature must be the contents of the `.sig` file generated by the Tauri bundler, as a string." + )] SignatureUtf8(String), #[cfg(all(target_os = "windows", feature = "zip"))] /// `zip` errors. diff --git a/plugins/updater/src/lib.rs b/plugins/updater/src/lib.rs index 8e58a4029..d4fd06c59 100644 --- a/plugins/updater/src/lib.rs +++ b/plugins/updater/src/lib.rs @@ -24,8 +24,8 @@ use std::{ffi::OsString, sync::Arc}; use http::{HeaderMap, HeaderName, HeaderValue}; use semver::Version; use tauri::{ - plugin::{Builder as PluginBuilder, TauriPlugin}, Manager, Runtime, + plugin::{Builder as PluginBuilder, TauriPlugin}, }; mod commands; diff --git a/plugins/updater/src/updater.rs b/plugins/updater/src/updater.rs index 809cd0065..515eb9399 100644 --- a/plugins/updater/src/updater.rs +++ b/plugins/updater/src/updater.rs @@ -17,28 +17,28 @@ use std::ffi::OsStr; use base64::Engine; use futures_util::StreamExt; -use http::{header::ACCEPT, HeaderName}; +use http::{HeaderName, header::ACCEPT}; use minisign_verify::{PublicKey, Signature}; use percent_encoding::{AsciiSet, CONTROLS}; use reqwest::{ - header::{HeaderMap, HeaderValue}, ClientBuilder, StatusCode, + header::{HeaderMap, HeaderValue}, }; use semver::Version; -use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize}; +use serde::{Deserialize, Deserializer, Serialize, de::Error as DeError}; use tauri::{ + AppHandle, Resource, Runtime, utils::{ config::BundleType, platform::{bundle_type, current_exe}, }, - AppHandle, Resource, Runtime, }; use time::OffsetDateTime; use url::Url; use crate::{ - error::{Error, Result}, Config, + error::{Error, Result}, }; const UPDATER_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),); @@ -937,8 +937,8 @@ impl Update { /// └── ... fn install_inner(&self, bytes: &[u8]) -> Result<()> { use windows_sys::{ - w, Win32::UI::{Shell::ShellExecuteW, WindowsAndMessaging::SW_SHOW}, + w, }; let updater_type = self.extract(bytes)?; @@ -1185,8 +1185,8 @@ impl Update { let decoder = flate2::read::GzDecoder::new(archive); let mut archive = tar::Archive::new(decoder); for mut entry in archive.entries()?.flatten() { - if let Ok(path) = entry.path() { - if path.extension() == Some(OsStr::new("AppImage")) { + if let Ok(path) = entry.path() + && path.extension() == Some(OsStr::new("AppImage")) { // if something went wrong during the extraction, we should restore previous app if let Err(err) = entry.unpack(&self.extract_path) { std::fs::rename(tmp_app_image, &self.extract_path)?; @@ -1195,7 +1195,6 @@ impl Update { // early finish we have everything we need here return Ok(()); } - } } // if we have not returned early we should restore the backup std::fs::rename(tmp_app_image, &self.extract_path)?; @@ -1289,20 +1288,17 @@ impl Update { .arg(install_arg) .arg(pkg_path) .status() - { - if status.success() { + && status.success() { log::debug!("installed {pkg_path:?} with pkexec"); return Ok(()); } - } // 2. Try zenity or kdialog for a graphical sudo experience - if let Ok(password) = self.get_password_graphically() { - if self.install_with_sudo(pkg_path, &password, install_cmd, install_arg)? { + if let Ok(password) = self.get_password_graphically() + && self.install_with_sudo(pkg_path, &password, install_cmd, install_arg)? { log::debug!("installed {pkg_path:?} with GUI sudo"); return Ok(()); } - } // 3. Final fallback: terminal sudo let status = std::process::Command::new("sudo") @@ -1329,22 +1325,20 @@ impl Update { ]) .output(); - if let Ok(output) = zenity_result { - if output.status.success() { + if let Ok(output) = zenity_result + && output.status.success() { return Ok(String::from_utf8_lossy(&output.stdout).trim().to_string()); } - } // Fall back to kdialog if zenity fails or isn't available let kdialog_result = std::process::Command::new("kdialog") .args(["--password", "Enter your password to install the update:"]) .output(); - if let Ok(output) = kdialog_result { - if output.status.success() { + if let Ok(output) = kdialog_result + && output.status.success() { return Ok(String::from_utf8_lossy(&output.stdout).trim().to_string()); } - } Err(Error::AuthenticationFailed) } diff --git a/plugins/updater/tests/app-updater/tests/update.rs b/plugins/updater/tests/app-updater/tests/update.rs index 20099d398..6cf13a03e 100644 --- a/plugins/updater/tests/app-updater/tests/update.rs +++ b/plugins/updater/tests/app-updater/tests/update.rs @@ -818,7 +818,8 @@ fn run_update_cases( if code != expected_exit_code { panic!( - "failed to run app bundled as {}, expected exit code {expected_exit_code}, got {code}", bundle_target.name() + "failed to run app bundled as {}, expected exit code {expected_exit_code}, got {code}", + bundle_target.name() ); } #[cfg(windows)] diff --git a/plugins/updater/tests/updater-migration/tests/update.rs b/plugins/updater/tests/updater-migration/tests/update.rs index 813da3c61..49f1bc98e 100644 --- a/plugins/updater/tests/updater-migration/tests/update.rs +++ b/plugins/updater/tests/updater-migration/tests/update.rs @@ -32,7 +32,7 @@ fn npm_command() -> Command { } mod v1 { - use super::{npm_command, BundleTarget, UPDATER_PRIVATE_KEY}; + use super::{BundleTarget, UPDATER_PRIVATE_KEY, npm_command}; use serde::Serialize; use std::{ path::{Path, PathBuf}, diff --git a/plugins/updater/tests/updater-migration/v1-app/Cargo.toml b/plugins/updater/tests/updater-migration/v1-app/Cargo.toml index e99e4108d..510c4229f 100644 --- a/plugins/updater/tests/updater-migration/v1-app/Cargo.toml +++ b/plugins/updater/tests/updater-migration/v1-app/Cargo.toml @@ -3,7 +3,7 @@ workspace = {} [package] name = "app-updater-v1" version = "0.1.0" -edition = "2021" +edition = "2024" [build-dependencies] tauri-build = { version = "1", features = [] } diff --git a/plugins/upload/src/lib.rs b/plugins/upload/src/lib.rs index 7cffb358f..4ce1058de 100644 --- a/plugins/upload/src/lib.rs +++ b/plugins/upload/src/lib.rs @@ -21,12 +21,11 @@ mod transfer_stats; use transfer_stats::TransferStats; use futures_util::TryStreamExt; -use serde::{ser::Serializer, Deserialize, Serialize}; +use serde::{Deserialize, Serialize, ser::Serializer}; use tauri::{ - command, + Runtime, command, ipc::Channel, plugin::{Builder as PluginBuilder, TauriPlugin}, - Runtime, }; use tokio::{ fs::File, diff --git a/plugins/websocket/examples/tauri-app/src-tauri/Cargo.toml b/plugins/websocket/examples/tauri-app/src-tauri/Cargo.toml index 7c719eb3b..c3613b64a 100644 --- a/plugins/websocket/examples/tauri-app/src-tauri/Cargo.toml +++ b/plugins/websocket/examples/tauri-app/src-tauri/Cargo.toml @@ -2,7 +2,7 @@ name = "websocket-example" version = "0.1.0" description = "A Tauri App" -edition = "2021" +edition = "2024" [dependencies] serde = { workspace = true } diff --git a/plugins/websocket/src/lib.rs b/plugins/websocket/src/lib.rs index 15c7fa2b4..35a0cb421 100644 --- a/plugins/websocket/src/lib.rs +++ b/plugins/websocket/src/lib.rs @@ -18,13 +18,13 @@ html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" )] -use futures_util::{stream::SplitSink, SinkExt, StreamExt}; +use futures_util::{SinkExt, StreamExt, stream::SplitSink}; use http::header::{HeaderName, HeaderValue}; -use serde::{ser::Serializer, Deserialize, Serialize}; +use serde::{Deserialize, Serialize, ser::Serializer}; use tauri::{ + Manager, Runtime, State, Window, ipc::Channel, plugin::{Builder as PluginBuilder, TauriPlugin}, - Manager, Runtime, State, Window, }; use tokio::{net::TcpStream, sync::Mutex}; #[cfg(any( @@ -40,12 +40,12 @@ use tokio_tungstenite::connect_async_tls_with_config; )))] use tokio_tungstenite::connect_async_with_config; use tokio_tungstenite::{ + Connector, MaybeTlsStream, WebSocketStream, tungstenite::{ + Message, client::IntoClientRequest, protocol::{CloseFrame as ProtocolCloseFrame, WebSocketConfig}, - Message, }, - Connector, MaybeTlsStream, WebSocketStream, }; use std::collections::HashMap; diff --git a/plugins/window-state/src/cmd.rs b/plugins/window-state/src/cmd.rs index 8b376aa90..baadc01fb 100644 --- a/plugins/window-state/src/cmd.rs +++ b/plugins/window-state/src/cmd.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use crate::{AppHandleExt, StateFlags, WindowExt}; -use tauri::{command, AppHandle, Manager, Runtime}; +use tauri::{AppHandle, Manager, Runtime, command}; fn get_state_flags( app: &AppHandle, diff --git a/plugins/window-state/src/lib.rs b/plugins/window-state/src/lib.rs index 21c5a2350..8aeab6a44 100644 --- a/plugins/window-state/src/lib.rs +++ b/plugins/window-state/src/lib.rs @@ -13,9 +13,9 @@ use bitflags::bitflags; use serde::{Deserialize, Serialize}; use tauri::{ - plugin::{Builder as PluginBuilder, TauriPlugin}, AppHandle, Manager, Monitor, PhysicalPosition, PhysicalSize, RunEvent, Runtime, WebviewWindow, Window, WindowEvent, + plugin::{Builder as PluginBuilder, TauriPlugin}, }; use std::{