From: Stephen Seo Date: Wed, 15 Sep 2021 09:18:27 +0000 (+0900) Subject: Minor tweaks and cargo fmt X-Git-Tag: 0.1.0~44 X-Git-Url: https://git.seodisparate.com/tbm-edit-levitation.png?a=commitdiff_plain;h=ff327469f855d9a85480f318132eb98f3cca4e4a;p=mpd_info_screen Minor tweaks and cargo fmt --- diff --git a/src/main.rs b/src/main.rs index 4e6a6d6..0b2c7b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -155,7 +155,11 @@ fn info_loop(shared_data: Arc>) -> Result<(), String> { let mut saved: Vec = Vec::new(); let mut saved_str: String = String::new(); loop { - if !shared_data.lock().map_err(|_| String::from("Failed to get shared_data.thread_running"))?.thread_running { + if !shared_data + .lock() + .map_err(|_| String::from("Failed to get shared_data.thread_running"))? + .thread_running + { break; } { @@ -172,7 +176,9 @@ fn info_loop(shared_data: Arc>) -> Result<(), String> { init = false; println!("Got initial \"OK\" from MPD"); } else { - return Err(String::from("Did not get expected init message from MPD")); + return Err(String::from( + "Did not get expected init message from MPD", + )); } } else { // TODO handling of other messages @@ -188,7 +194,7 @@ fn info_loop(shared_data: Arc>) -> Result<(), String> { } // TODO send messages to get info - thread::sleep(Duration::from_millis(100)); + thread::sleep(Duration::from_millis(50)); } Ok(()) } @@ -198,7 +204,9 @@ fn main() -> Result<(), String> { println!("Got host addr == {}, port == {}", opt.host, opt.port); let connection = get_connection(opt.host, opt.port)?; - connection.set_read_timeout(Some(Duration::from_millis(100))).expect("Should be able to set timeout for TcpStream reads"); + connection + .set_read_timeout(Some(Duration::from_millis(50))) + .expect("Should be able to set timeout for TcpStream reads"); let shared_data = Arc::new(Mutex::new(Shared::new(connection))); let thread_shared_data = shared_data.clone(); @@ -210,7 +218,10 @@ fn main() -> Result<(), String> { thread::sleep(Duration::from_secs(5)); println!("Stopping thread..."); - shared_data.lock().map_err(|_| String::from("Failed to get shared_data.thread_running in main"))?.thread_running = false; + shared_data + .lock() + .map_err(|_| String::from("Failed to get shared_data.thread_running in main"))? + .thread_running = false; println!("Waiting on thread..."); thread::sleep(Duration::from_secs(5));