From 3535da9a3996a7d8a300cfe855c1ed9ff173ae28 Mon Sep 17 00:00:00 2001 From: Nickiel12 Date: Wed, 21 Dec 2022 19:19:19 -0800 Subject: [PATCH] internal: casts server response to server rsp type --- src/main.rs | 5 ++++- src/message_types.rs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6525da0..6c5023a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,6 +40,7 @@ struct CliArgs { value_parser(["title", "artist", "album"]) )] search_field: Option, + // Add flag for "search filepaths too" } fn main() { @@ -78,6 +79,8 @@ fn main() { socket.write_message(Message::Text(message_string)).unwrap(); let msg = socket.read_message().expect("Error reading message"); - println!("Received: {}", msg); + let resp: message_types::ServerResponse = + serde_json::from_str(msg.into_text().unwrap().as_str()).unwrap(); + println!("recieved: {:?}", resp); socket.close(None).unwrap(); } diff --git a/src/message_types.rs b/src/message_types.rs index d68cb8c..1c8fea5 100644 --- a/src/message_types.rs +++ b/src/message_types.rs @@ -18,7 +18,7 @@ impl Default for ItemTag { artist: String::new(), album: String::new(), album_artist: String::new(), - } + } } } @@ -73,7 +73,7 @@ impl PartialTag { } } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] pub struct ServerResponse { pub search_results: Vec, }