use async_mpd::Error;
use std::time::Duration;
use async_std as runtime;
#[runtime::main]
async fn main() -> Result<(), Error> {
let mut mpd = async_mpd::MpdClient::new("localhost:6600").await?;
loop {
let status = match mpd.status().await {
Ok(status) => status,
Err(Error::Disconnected) => {
println!("Server disconnected. Reconnecting");
mpd.reconnect().await?;
continue;
}
Err(other) => {
println!("Error: {:?}", other);
break;
}
};
println!("Status: {:?}", status);
runtime::task::sleep(Duration::from_secs(120)).await;
}
Ok(())
}