1
0

UUID implements copy so borrows are unnecessary. (#1154)

This commit is contained in:
Corey Shupe
2024-05-09 13:25:53 -04:00
committed by GitHub
parent e1a748016a
commit 53007465cd
4 changed files with 18 additions and 18 deletions

View File

@@ -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<bool> {
pub async fn has_finished_by_uuid(uuid: Uuid) -> crate::Result<bool> {
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<Option<i32>> {
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

View File

@@ -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,

View File

@@ -604,8 +604,8 @@ impl Children {
}
// Returns a ref to the child
pub fn get(&self, uuid: &Uuid) -> Option<Arc<RwLock<MinecraftChild>>> {
self.0.get(uuid).cloned()
pub fn get(&self, uuid: Uuid) -> Option<Arc<RwLock<MinecraftChild>>> {
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<Option<i32>> {
pub async fn exit_status(&self, uuid: Uuid) -> crate::Result<Option<i32>> {
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<Vec<Uuid>> {
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<Vec<ProfilePathId>> {
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<Vec<Profile>> {
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

View File

@@ -21,7 +21,7 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
// Checks if a process has finished by process UUID
#[tauri::command]
pub async fn process_has_finished_by_uuid(uuid: Uuid) -> Result<bool> {
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<bool> {
pub async fn process_get_exit_status_by_uuid(
uuid: Uuid,
) -> Result<Option<i32>> {
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<Vec<Profile>> {
// 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?)
}