🔨 chore(core): remove unneeded Uuid borrows

This commit is contained in:
Pauline 2024-05-11 04:43:51 +02:00
parent 35ef702f5c
commit 7b3a89e055
No known key found for this signature in database
GPG key ID: 722BB181973296AE
3 changed files with 14 additions and 14 deletions

View file

@ -6,13 +6,13 @@ use uuid::Uuid;
/// check whether or not a process has completed by its [`Uuid`].
#[tracing::instrument]
pub async fn uuid_is_finished(uuid: &Uuid) -> crate::Result<bool> {
pub async fn uuid_is_finished(uuid: Uuid) -> crate::Result<bool> {
Ok(uuid_exit_status(uuid).await?.is_some())
}
/// check the exit status of a process by its [`Uuid`].
#[tracing::instrument]
pub async fn uuid_exit_status(uuid: &Uuid) -> crate::Result<Option<i32>> {
pub async fn uuid_exit_status(uuid: Uuid) -> crate::Result<Option<i32>> {
let state = State::get().await?;
let processor = state.processor.read().await;
processor.exit_status(uuid).await
@ -60,7 +60,7 @@ pub async fn get_uuids_by_cluster_path(cluster_path: ClusterPath) -> crate::Resu
/// kill an existing and running process by its [`Uuid`]
#[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 processor = state.processor.read().await;
@ -74,7 +74,7 @@ pub async fn kill_by_uuid(uuid: &Uuid) -> crate::Result<()> {
/// wait for a child process to finish running its manager by its [`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 processor = state.processor.read().await;

View file

@ -92,7 +92,7 @@ pub fn minecraft_arguments(
arg,
&creds.access_token,
&creds.username,
&creds.id,
creds.id,
version,
asset_index,
game_directory,
@ -112,7 +112,7 @@ pub fn minecraft_arguments(
&arg.replace(' ', DUMMY_REPLACE_NEWLINE),
&creds.access_token,
&creds.username,
&creds.id,
creds.id,
version,
asset_index,
game_directory,
@ -192,7 +192,7 @@ fn parse_minecraft_argument(
argument: &str,
access_token: &str,
username: &str,
uuid: &uuid::Uuid,
uuid: uuid::Uuid,
version: &str,
asset_index: &str,
game_directory: &Path,

View file

@ -264,8 +264,8 @@ impl Processor {
}
/// Returns a reference to the value corresponding to the key.
pub fn get(&self, uuid: &Uuid) -> Option<Arc<RwLock<ProcessorChild>>> {
self.0.get(uuid).cloned()
pub fn get(&self, uuid: Uuid) -> Option<Arc<RwLock<ProcessorChild>>> {
self.0.get(&uuid).cloned()
}
/// An collection visiting all keys in arbitrary order.
@ -277,7 +277,7 @@ impl Processor {
pub async fn running(&self) -> crate::Result<Vec<Uuid>> {
let mut keys = Vec::new();
for key in self.keys() {
if let Some(process) = self.get(&key) {
if let Some(process) = self.get(key) {
let process = process.clone();
let process = process.write().await;
if process
@ -300,7 +300,7 @@ impl Processor {
let running = self.running().await?;
let mut keys = Vec::new();
for key in running {
if let Some(process) = self.get(&key) {
if let Some(process) = self.get(key) {
let process = process.clone();
let process = process.read().await;
if process.cluster_path == cluster_path {
@ -315,7 +315,7 @@ impl Processor {
pub async fn running_cluster_paths(&self) -> crate::Result<Vec<ClusterPath>> {
let mut clusters = Vec::new();
for key in self.keys() {
if let Some(process) = self.get(&key) {
if let Some(process) = self.get(key) {
let process = process.clone();
let process = process.write().await;
if process
@ -337,7 +337,7 @@ impl Processor {
pub async fn running_clusters(&self) -> crate::Result<Vec<Cluster>> {
let mut clusters = Vec::new();
for key in self.keys() {
if let Some(process) = self.get(&key) {
if let Some(process) = self.get(key) {
let process = process.clone();
let process = process.write().await;
if process
@ -359,7 +359,7 @@ impl Processor {
}
/// get the exit status of a process by its [`Uuid`].
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(process) = self.get(uuid) {
let process = process.write().await;
let status = process.current_child.write().await.try_wait().await?;