diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2022-08-07 20:47:54 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2022-08-07 20:47:54 -0400 |
| commit | ea77a8cf9c012fcd877d842fec85b0b5a442952c (patch) | |
| tree | 7f209c030b97a957497f152d161a9d7035311132 /vendored/mpd/examples | |
| parent | 0de7e9ac43f88aae3750ecfe25b5454fdd1ad015 (diff) | |
Diffstat (limited to 'vendored/mpd/examples')
| -rw-r--r-- | vendored/mpd/examples/example.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/vendored/mpd/examples/example.rs b/vendored/mpd/examples/example.rs new file mode 100644 index 0000000..f4ae079 --- /dev/null +++ b/vendored/mpd/examples/example.rs @@ -0,0 +1,24 @@ +extern crate mpd; + +use mpd::{Client, Query}; +use std::net::TcpStream; + +fn main() -> Result<(), Box<dyn std::error::Error>> { + let mut c = Client::new(TcpStream::connect("127.0.0.1:6600").unwrap()).unwrap(); + println!("version: {:?}", c.version); + println!("status: {:?}", c.status()); + println!("stuff: {:?}", c.find(&Query::new(), (1, 2))); + + let now_playing = c.currentsong()?; + if let Some(song) = now_playing { + println!("Metadata:"); + for row in c.readcomments(song)? { + if let Ok((k, v)) = row { + println!("{}: {}", k, v); + } + } + } else { + println!("No song playing."); + } + Ok(()) +} |