From 95fa3d72ace4d92f235ac0da1f5333a50201d441 Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Thu, 11 May 2023 23:22:36 +0200 Subject: refactor: Move some functions to utility module (#347) * refactor: Move `force_panic` to utility module * refactor: Move `is_debug_mode` to utility module --- src-tauri/src/main.rs | 19 ++++--------------- src-tauri/src/util.rs | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 src-tauri/src/util.rs (limited to 'src-tauri') diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 4fcb4b63..6b90093e 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -31,6 +31,8 @@ use northstar::get_northstar_version_number; mod thunderstore; use thunderstore::query_thunderstore_packages_api; +mod util; + use semver::Version; use serde::{Deserialize, Serialize}; use tauri::{Manager, Runtime}; @@ -119,7 +121,7 @@ fn main() { }) .manage(Counter(Default::default())) .invoke_handler(tauri::generate_handler![ - force_panic, + util::force_panic, find_game_install_location_caller, get_flightcore_version_number, get_northstar_version_number_caller, @@ -135,7 +137,7 @@ fn main() { repair_and_verify::verify_game_files, mod_management::set_mod_enabled_status, repair_and_verify::disable_all_but_core, - is_debug_mode, + util::is_debug_mode, github::release_notes::get_northstar_release_notes, linux_checks, mod_management::get_installed_mods_and_properties, @@ -201,19 +203,6 @@ async fn find_game_install_location_caller() -> Result { find_game_install_location() } -/// This function's only use is to force a `panic!()` -// This must NOT be async to ensure crashing whole application. -#[tauri::command] -fn force_panic() { - panic!("Force panicked!"); -} - -/// Returns true if built in debug mode -#[tauri::command] -async fn is_debug_mode() -> bool { - cfg!(debug_assertions) -} - /// Returns true if linux compatible #[tauri::command] async fn linux_checks() -> Result<(), String> { diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs new file mode 100644 index 00000000..0c2c5da4 --- /dev/null +++ b/src-tauri/src/util.rs @@ -0,0 +1,14 @@ +//! This module contains various utility/helper functions that do not fit into any other module + +/// This function's only use is to force a `panic!()` +// This must NOT be async to ensure crashing whole application. +#[tauri::command] +pub fn force_panic() { + panic!("Force panicked!"); +} + +/// Returns true if built in debug mode +#[tauri::command] +pub async fn is_debug_mode() -> bool { + cfg!(debug_assertions) +} -- cgit v1.2.3