From efc73518d776ea35c2c365a769c0ba1f711e30ba Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 14 Jul 2025 20:48:53 -0400 Subject: [PATCH] Code formatting --- src/api.rs | 5 +---- src/main.rs | 36 +++++++++++++++++++++++++----------- src/the_rest.rs | 33 +++++++++++++++++++-------------- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src/api.rs b/src/api.rs index 5a2e330..f4d0933 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,6 +1,4 @@ -pub async fn fetch_next_queue_item( - base_url: &String, -) -> Result { +pub async fn fetch_next_queue_item(base_url: &String) -> Result { let client = reqwest::Client::new(); let fetch_endpoint = String::from("api/v2/song/queue/next"); let api_url = format!("{base_url}/{fetch_endpoint}"); @@ -131,4 +129,3 @@ pub mod get_coverart_queue { } } } - diff --git a/src/main.rs b/src/main.rs index c4b1da7..7bb1141 100644 --- a/src/main.rs +++ b/src/main.rs @@ -94,9 +94,19 @@ async fn some_work( let user_id = uuid::Uuid::new_v4(); // TODO: Place this somewhere else let song_type = String::from("flac"); - // Err(std::io::Error::other(err.to_string())) - match the_rest::create_song::create(app_base_url, &metadata, &user_id, &song_type).await { - Ok(response) => match response.json::().await { + // Err(std::io::Error::other(err.to_string())) + match the_rest::create_song::create( + app_base_url, + &metadata, + &user_id, + &song_type, + ) + .await + { + Ok(response) => match response + .json::() + .await + { Ok(resp) => { println!("Response: {resp:?}"); @@ -111,13 +121,9 @@ async fn some_work( // println!("Response json: {:?}", response.text().await); Ok(()) } - Err(err) => { - Err(std::io::Error::other(err.to_string())) - } - } - Err(err) => { - Err(std::io::Error::other(err.to_string())) - } + Err(err) => Err(std::io::Error::other(err.to_string())), + }, + Err(err) => Err(std::io::Error::other(err.to_string())), } } Err(err) => Err(std::io::Error::other(err.to_string())), @@ -136,7 +142,15 @@ async fn some_work( async fn prep_song( api_url: &String, song_queue_id: &uuid::Uuid, -) -> Result<(String, String, api::get_metadata_queue::response::Metadata, uuid::Uuid), reqwest::Error> { +) -> Result< + ( + String, + String, + api::get_metadata_queue::response::Metadata, + uuid::Uuid, + ), + 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 3cc35f0..8afffe7 100644 --- a/src/the_rest.rs +++ b/src/the_rest.rs @@ -2,8 +2,13 @@ // TODO: Create song pub mod create_song { -pub async fn create(base_url: &String, metadata_queue: &crate::api::get_metadata_queue::response::Metadata, user_id: &uuid::Uuid, song_type: &String) -> Result { - let payload = serde_json::json!( + pub async fn create( + base_url: &String, + metadata_queue: &crate::api::get_metadata_queue::response::Metadata, + user_id: &uuid::Uuid, + song_type: &String, + ) -> Result { + let payload = serde_json::json!( { "album": &metadata_queue.album, "album_artist": &metadata_queue.album_artist, @@ -22,21 +27,21 @@ pub async fn create(base_url: &String, metadata_queue: &crate::api::get_metadata } ); - let client = reqwest::Client::builder().build()?; + let client = reqwest::Client::builder().build()?; - let url = format!("{base_url}/api/v2/song"); + let url = format!("{base_url}/api/v2/song"); - let request = client.post(url).json(&payload); - request.send().await -} - -pub mod response { - #[derive(Debug, serde::Deserialize, serde::Serialize)] - pub struct Response { - pub message: String, - pub data: Vec, + let request = client.post(url).json(&payload); + request.send().await + } + + pub mod response { + #[derive(Debug, serde::Deserialize, serde::Serialize)] + pub struct Response { + pub message: String, + pub data: Vec, + } } -} } // TODO: Create coverart