async-mpd

Crates.ioasync-mpd
lib.rsasync-mpd
version0.6.0
sourcesrc
created_at2020-05-28 17:47:35.695459
updated_at2021-08-29 13:16:32.30278
descriptionAsync Mpd client library
homepage
repositoryhttps://github.com/jkristell/async-mpd
max_upload_size
id247107
size73,909
Johan Kristell (jkristell)

documentation

README

crates.io version docs.rs

async-mpd

Runtime agnostic Mpd client library for Rust

Example:

use tokio as runtime;
// For async-std instead
//use async_std as runtime;
use async_mpd::{MpdClient, cmd};

#[runtime::main]
async fn main() -> Result<(), async_mpd::Error> {
    // Connect to server
    let mut mpd = MpdClient::new();
    mpd.connect("localhost:6600").await?;

    // Get all tracks in the play queue and display them
    let queue = mpd.queue().await?;
    for track in queue {
        println!("{:?} - {:?}", track.artist, track.title);
    }

    // Play track nr 2 in the queue
    mpd.playid(2).await?;

    // Get and print the current server status using the command api
    let status = mpd.exec(cmd::Status).await?;
    println!("{:?}", status);

    // Set the volume to 50%
    mpd.setvol(50).await?;

    Ok(())
}
Commit count: 44

cargo fmt