let mut saved: Vec<u8> = 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;
}
{
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
}
// TODO send messages to get info
- thread::sleep(Duration::from_millis(100));
+ thread::sleep(Duration::from_millis(50));
}
Ok(())
}
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();
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));