From 47a3b60b8d03caaa53c32024d3e8cabbe80ed864 Mon Sep 17 00:00:00 2001 From: phoenix Date: Fri, 27 Jun 2025 21:03:56 -0400 Subject: [PATCH] Code formatting --- src/main.rs | 36 ++++++++++++++++++++++-------------- src/the_rest.rs | 2 -- src/update_queued_song.rs | 22 +++++++++++++--------- src/util.rs | 2 -- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8852fd9..5b2cd4d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,8 +23,7 @@ async fn main() -> Result<(), Box> { // TODO: Do something with the result later // let _ = prep_song(&app_base_url, &song_queue_id).await; match some_work(&app_base_url, &song_queue_id).await { - Ok(_) => { - } + Ok(_) => {} Err(err) => { eprintln!("Error: {:?}", err); } @@ -66,19 +65,27 @@ async fn is_queue_empty( } } -async fn some_work(app_base_url: &String, song_queue_id: &uuid::Uuid) -> Result<(), std::io::Error> { +async fn some_work( + app_base_url: &String, + song_queue_id: &uuid::Uuid, +) -> Result<(), std::io::Error> { match prep_song(app_base_url, song_queue_id).await { Ok((song_queue_path, coverart_queue_path, metadata)) => { match apply_metadata(&song_queue_path, &coverart_queue_path, &metadata).await { Ok(_applied) => { // let s_path = util::path_buf_to_string(&song_queue_path); - match update_queued_song::update_queued_song(app_base_url, &song_queue_path, song_queue_id).await { - Ok(_response) => { - Ok(()) - } - Err(err) => { - Err(std::io::Error::new(std::io::ErrorKind::Other, err.to_string())) - } + match update_queued_song::update_queued_song( + app_base_url, + &song_queue_path, + song_queue_id, + ) + .await + { + Ok(_response) => Ok(()), + Err(err) => Err(std::io::Error::new( + std::io::ErrorKind::Other, + err.to_string(), + )), } // Ok((s_path)) } @@ -88,13 +95,14 @@ async fn some_work(app_base_url: &String, song_queue_id: &uuid::Uuid) -> Result< } } } - Err(_err) => { - Ok(()) - } + Err(_err) => Ok(()), } } -async fn prep_song(api_url: &String, song_queue_id: &uuid::Uuid) -> Result<(String, String, api::get_metadata_queue::response::Metadata), reqwest::Error> { +async fn prep_song( + api_url: &String, + song_queue_id: &uuid::Uuid, +) -> Result<(String, String, api::get_metadata_queue::response::Metadata), reqwest::Error> { match api::fetch_song_queue_data::get_data(api_url, song_queue_id).await { Ok(response) => { // Process data here... diff --git a/src/the_rest.rs b/src/the_rest.rs index 125aab4..ae021fd 100644 --- a/src/the_rest.rs +++ b/src/the_rest.rs @@ -1,7 +1,5 @@ // TODO: Refactor this file when this app is functional - - // TODO: Create song // TODO: Create coverart // TODO: Wipe data from queued song diff --git a/src/update_queued_song.rs b/src/update_queued_song.rs index d731096..56cb753 100644 --- a/src/update_queued_song.rs +++ b/src/update_queued_song.rs @@ -1,18 +1,23 @@ - use reqwest::multipart; // TODO: Update the queued song with the updated queued song -pub async fn update_queued_song(base_url: &String, song_path: &String, song_queue_id: &uuid::Uuid) -> Result { - let client = reqwest::Client::builder() - .build()?; +pub async fn update_queued_song( + base_url: &String, + song_path: &String, + song_queue_id: &uuid::Uuid, +) -> Result { + let client = reqwest::Client::builder().build()?; - let form = reqwest::multipart::Form::new() - .part("file", - reqwest::multipart::Part::bytes(std::fs::read(song_path).unwrap()).file_name("track01.flac")); + let form = reqwest::multipart::Form::new().part( + "file", + reqwest::multipart::Part::bytes(std::fs::read(song_path).unwrap()) + .file_name("track01.flac"), + ); let method = "PATCH"; let url = format!("{}/api/v2/song/queue/{}", base_url, song_queue_id); - let request = client.request(reqwest::Method::from_bytes(method.as_bytes()).unwrap(), url) + let request = client + .request(reqwest::Method::from_bytes(method.as_bytes()).unwrap(), url) .multipart(form); let response = request.send().await?; @@ -20,7 +25,6 @@ pub async fn update_queued_song(base_url: &String, song_path: &String, song_queu Ok(response) } - pub mod response { use serde::{Deserialize, Serialize}; } diff --git a/src/util.rs b/src/util.rs index c55ded3..77a0b4e 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,4 +1,3 @@ - pub fn path_buf_to_string(path: &std::path::PathBuf) -> String { let s_path = match path.to_str() { Some(val) => String::from(val), @@ -7,4 +6,3 @@ pub fn path_buf_to_string(path: &std::path::PathBuf) -> String { s_path } -