From 07277a84a1858c0d7631fe10f80a3d5b99dd3335 Mon Sep 17 00:00:00 2001 From: Corey Shupe Date: Fri, 26 Apr 2024 09:10:41 -0400 Subject: [PATCH] UUID implements copy so borrows are unnecessary. --- theseus/src/api/process.rs | 8 ++++---- theseus/src/launcher/args.rs | 6 +++--- theseus/src/state/children.rs | 14 +++++++------- theseus_gui/src-tauri/src/api/process.rs | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/theseus/src/api/process.rs b/theseus/src/api/process.rs index 3fb3bc6f1..561c801cd 100644 --- a/theseus/src/api/process.rs +++ b/theseus/src/api/process.rs @@ -12,14 +12,14 @@ pub use crate::{ // Gets whether a child process stored in the state by UUID has finished #[tracing::instrument] -pub async fn has_finished_by_uuid(uuid: &Uuid) -> crate::Result { +pub async fn has_finished_by_uuid(uuid: Uuid) -> crate::Result { Ok(get_exit_status_by_uuid(uuid).await?.is_some()) } // Gets the exit status of a child process stored in the state by UUID #[tracing::instrument] pub async fn get_exit_status_by_uuid( - uuid: &Uuid, + uuid: Uuid, ) -> crate::Result> { let state = State::get().await?; let children = state.children.read().await; @@ -71,7 +71,7 @@ pub async fn get_uuids_by_profile_path( // Kill a child process stored in the state by UUID, as a string #[tracing::instrument] -pub async fn kill_by_uuid(uuid: &Uuid) -> crate::Result<()> { +pub async fn kill_by_uuid(uuid: Uuid) -> crate::Result<()> { let state = State::get().await?; let children = state.children.read().await; if let Some(mchild) = children.get(uuid) { @@ -85,7 +85,7 @@ pub async fn kill_by_uuid(uuid: &Uuid) -> crate::Result<()> { // Wait for a child process stored in the state by UUID #[tracing::instrument] -pub async fn wait_for_by_uuid(uuid: &Uuid) -> crate::Result<()> { +pub async fn wait_for_by_uuid(uuid: Uuid) -> crate::Result<()> { let state = State::get().await?; let children = state.children.read().await; // No error returned for already killed process diff --git a/theseus/src/launcher/args.rs b/theseus/src/launcher/args.rs index c36a37489..e7bd15098 100644 --- a/theseus/src/launcher/args.rs +++ b/theseus/src/launcher/args.rs @@ -217,7 +217,7 @@ pub fn get_minecraft_arguments( arg, &credentials.access_token, &credentials.username, - &credentials.id, + credentials.id, version, asset_index_name, game_directory, @@ -237,7 +237,7 @@ pub fn get_minecraft_arguments( &x.replace(' ', TEMPORARY_REPLACE_CHAR), &credentials.access_token, &credentials.username, - &credentials.id, + credentials.id, version, asset_index_name, game_directory, @@ -257,7 +257,7 @@ fn parse_minecraft_argument( argument: &str, access_token: &str, username: &str, - uuid: &Uuid, + uuid: Uuid, version: &str, asset_index_name: &str, game_directory: &Path, diff --git a/theseus/src/state/children.rs b/theseus/src/state/children.rs index 4fa481856..f272276d4 100644 --- a/theseus/src/state/children.rs +++ b/theseus/src/state/children.rs @@ -604,8 +604,8 @@ impl Children { } // Returns a ref to the child - pub fn get(&self, uuid: &Uuid) -> Option>> { - self.0.get(uuid).cloned() + pub fn get(&self, uuid: Uuid) -> Option>> { + self.0.get(&uuid).cloned() } // Gets all PID keys @@ -615,7 +615,7 @@ impl Children { // Get exit status of a child by PID // Returns None if the child is still running - pub async fn exit_status(&self, uuid: &Uuid) -> crate::Result> { + pub async fn exit_status(&self, uuid: Uuid) -> crate::Result> { if let Some(child) = self.get(uuid) { let child = child.write().await; let status = child.current_child.write().await.try_wait().await?; @@ -629,7 +629,7 @@ impl Children { pub async fn running_keys(&self) -> crate::Result> { let mut keys = Vec::new(); for key in self.keys() { - if let Some(child) = self.get(&key) { + if let Some(child) = self.get(key) { let child = child.clone(); let child = child.write().await; if child @@ -655,7 +655,7 @@ impl Children { let running_keys = self.running_keys().await?; let mut keys = Vec::new(); for key in running_keys { - if let Some(child) = self.get(&key) { + if let Some(child) = self.get(key) { let child = child.clone(); let child = child.read().await; if child.profile_relative_path == profile_path { @@ -672,7 +672,7 @@ impl Children { ) -> crate::Result> { let mut profiles = Vec::new(); for key in self.keys() { - if let Some(child) = self.get(&key) { + if let Some(child) = self.get(key) { let child = child.clone(); let child = child.write().await; if child @@ -695,7 +695,7 @@ impl Children { pub async fn running_profiles(&self) -> crate::Result> { let mut profiles = Vec::new(); for key in self.keys() { - if let Some(child) = self.get(&key) { + if let Some(child) = self.get(key) { let child = child.clone(); let child = child.write().await; if child diff --git a/theseus_gui/src-tauri/src/api/process.rs b/theseus_gui/src-tauri/src/api/process.rs index d6dbc676d..08740dcb6 100644 --- a/theseus_gui/src-tauri/src/api/process.rs +++ b/theseus_gui/src-tauri/src/api/process.rs @@ -21,7 +21,7 @@ pub fn init() -> tauri::plugin::TauriPlugin { // Checks if a process has finished by process UUID #[tauri::command] pub async fn process_has_finished_by_uuid(uuid: Uuid) -> Result { - Ok(process::has_finished_by_uuid(&uuid).await?) + Ok(process::has_finished_by_uuid(uuid).await?) } // Gets process exit status by process UUID @@ -29,7 +29,7 @@ pub async fn process_has_finished_by_uuid(uuid: Uuid) -> Result { pub async fn process_get_exit_status_by_uuid( uuid: Uuid, ) -> Result> { - Ok(process::get_exit_status_by_uuid(&uuid).await?) + Ok(process::get_exit_status_by_uuid(uuid).await?) } // Gets all process UUIDs @@ -68,11 +68,11 @@ pub async fn process_get_all_running_profiles() -> Result> { // Kill a process by process UUID #[tauri::command] pub async fn process_kill_by_uuid(uuid: Uuid) -> Result<()> { - Ok(process::kill_by_uuid(&uuid).await?) + Ok(process::kill_by_uuid(uuid).await?) } // Wait for a process to finish by process UUID #[tauri::command] pub async fn process_wait_for_by_uuid(uuid: Uuid) -> Result<()> { - Ok(process::wait_for_by_uuid(&uuid).await?) + Ok(process::wait_for_by_uuid(uuid).await?) }