You've already forked AstralRinth
forked from didirus/AstralRinth
UUID implements copy so borrows are unnecessary. (#1154)
This commit is contained in:
@@ -12,14 +12,14 @@ pub use crate::{
|
|||||||
|
|
||||||
// Gets whether a child process stored in the state by UUID has finished
|
// Gets whether a child process stored in the state by UUID has finished
|
||||||
#[tracing::instrument]
|
#[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())
|
Ok(get_exit_status_by_uuid(uuid).await?.is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the exit status of a child process stored in the state by UUID
|
// Gets the exit status of a child process stored in the state by UUID
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub async fn get_exit_status_by_uuid(
|
pub async fn get_exit_status_by_uuid(
|
||||||
uuid: &Uuid,
|
uuid: Uuid,
|
||||||
) -> crate::Result<Option<i32>> {
|
) -> crate::Result<Option<i32>> {
|
||||||
let state = State::get().await?;
|
let state = State::get().await?;
|
||||||
let children = state.children.read().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
|
// Kill a child process stored in the state by UUID, as a string
|
||||||
#[tracing::instrument]
|
#[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 state = State::get().await?;
|
||||||
let children = state.children.read().await;
|
let children = state.children.read().await;
|
||||||
if let Some(mchild) = children.get(uuid) {
|
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
|
// Wait for a child process stored in the state by UUID
|
||||||
#[tracing::instrument]
|
#[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 state = State::get().await?;
|
||||||
let children = state.children.read().await;
|
let children = state.children.read().await;
|
||||||
// No error returned for already killed process
|
// No error returned for already killed process
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ pub fn get_minecraft_arguments(
|
|||||||
arg,
|
arg,
|
||||||
&credentials.access_token,
|
&credentials.access_token,
|
||||||
&credentials.username,
|
&credentials.username,
|
||||||
&credentials.id,
|
credentials.id,
|
||||||
version,
|
version,
|
||||||
asset_index_name,
|
asset_index_name,
|
||||||
game_directory,
|
game_directory,
|
||||||
@@ -237,7 +237,7 @@ pub fn get_minecraft_arguments(
|
|||||||
&x.replace(' ', TEMPORARY_REPLACE_CHAR),
|
&x.replace(' ', TEMPORARY_REPLACE_CHAR),
|
||||||
&credentials.access_token,
|
&credentials.access_token,
|
||||||
&credentials.username,
|
&credentials.username,
|
||||||
&credentials.id,
|
credentials.id,
|
||||||
version,
|
version,
|
||||||
asset_index_name,
|
asset_index_name,
|
||||||
game_directory,
|
game_directory,
|
||||||
@@ -257,7 +257,7 @@ fn parse_minecraft_argument(
|
|||||||
argument: &str,
|
argument: &str,
|
||||||
access_token: &str,
|
access_token: &str,
|
||||||
username: &str,
|
username: &str,
|
||||||
uuid: &Uuid,
|
uuid: Uuid,
|
||||||
version: &str,
|
version: &str,
|
||||||
asset_index_name: &str,
|
asset_index_name: &str,
|
||||||
game_directory: &Path,
|
game_directory: &Path,
|
||||||
|
|||||||
@@ -604,8 +604,8 @@ impl Children {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns a ref to the child
|
// Returns a ref to the child
|
||||||
pub fn get(&self, uuid: &Uuid) -> Option<Arc<RwLock<MinecraftChild>>> {
|
pub fn get(&self, uuid: Uuid) -> Option<Arc<RwLock<MinecraftChild>>> {
|
||||||
self.0.get(uuid).cloned()
|
self.0.get(&uuid).cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets all PID keys
|
// Gets all PID keys
|
||||||
@@ -615,7 +615,7 @@ impl Children {
|
|||||||
|
|
||||||
// Get exit status of a child by PID
|
// Get exit status of a child by PID
|
||||||
// Returns None if the child is still running
|
// 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) {
|
if let Some(child) = self.get(uuid) {
|
||||||
let child = child.write().await;
|
let child = child.write().await;
|
||||||
let status = child.current_child.write().await.try_wait().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>> {
|
pub async fn running_keys(&self) -> crate::Result<Vec<Uuid>> {
|
||||||
let mut keys = Vec::new();
|
let mut keys = Vec::new();
|
||||||
for key in self.keys() {
|
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.clone();
|
||||||
let child = child.write().await;
|
let child = child.write().await;
|
||||||
if child
|
if child
|
||||||
@@ -655,7 +655,7 @@ impl Children {
|
|||||||
let running_keys = self.running_keys().await?;
|
let running_keys = self.running_keys().await?;
|
||||||
let mut keys = Vec::new();
|
let mut keys = Vec::new();
|
||||||
for key in running_keys {
|
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.clone();
|
||||||
let child = child.read().await;
|
let child = child.read().await;
|
||||||
if child.profile_relative_path == profile_path {
|
if child.profile_relative_path == profile_path {
|
||||||
@@ -672,7 +672,7 @@ impl Children {
|
|||||||
) -> crate::Result<Vec<ProfilePathId>> {
|
) -> crate::Result<Vec<ProfilePathId>> {
|
||||||
let mut profiles = Vec::new();
|
let mut profiles = Vec::new();
|
||||||
for key in self.keys() {
|
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.clone();
|
||||||
let child = child.write().await;
|
let child = child.write().await;
|
||||||
if child
|
if child
|
||||||
@@ -695,7 +695,7 @@ impl Children {
|
|||||||
pub async fn running_profiles(&self) -> crate::Result<Vec<Profile>> {
|
pub async fn running_profiles(&self) -> crate::Result<Vec<Profile>> {
|
||||||
let mut profiles = Vec::new();
|
let mut profiles = Vec::new();
|
||||||
for key in self.keys() {
|
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.clone();
|
||||||
let child = child.write().await;
|
let child = child.write().await;
|
||||||
if child
|
if child
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
|||||||
// Checks if a process has finished by process UUID
|
// Checks if a process has finished by process UUID
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn process_has_finished_by_uuid(uuid: Uuid) -> Result<bool> {
|
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
|
// 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(
|
pub async fn process_get_exit_status_by_uuid(
|
||||||
uuid: Uuid,
|
uuid: Uuid,
|
||||||
) -> Result<Option<i32>> {
|
) -> 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
|
// 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
|
// Kill a process by process UUID
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn process_kill_by_uuid(uuid: Uuid) -> Result<()> {
|
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
|
// Wait for a process to finish by process UUID
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn process_wait_for_by_uuid(uuid: Uuid) -> Result<()> {
|
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?)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user