Struct MpdClient

Source
pub struct MpdClient { /* private fields */ }
Expand description

Mpd Client

Implementations§

Source§

impl MpdClient

Source

pub fn new() -> Self

Create a new MpdClient

Source

pub async fn connect<A: AsyncToSocketAddrs>( &mut self, addr: A, ) -> Result<String, Error>

Source

pub async fn reconnect(&mut self) -> Result<(), Error>

Source

pub async fn stats(&mut self) -> Result<Stats, Error>

Get stats on the music database

Source

pub async fn status(&mut self) -> Result<Status, Error>

Source

pub async fn update( &mut self, path: Option<&str>, ) -> Result<DatabaseVersion, Error>

Source

pub async fn rescan( &mut self, path: Option<&str>, ) -> Result<DatabaseVersion, Error>

Source

pub async fn idle(&mut self) -> Result<Subsystem, Error>

Source

pub async fn noidle(&mut self) -> Result<(), Error>

Source

pub async fn setvol(&mut self, volume: u32) -> Result<(), Error>

Source

pub async fn repeat(&mut self, repeat: bool) -> Result<(), Error>

Source

pub async fn random(&mut self, random: bool) -> Result<(), Error>

Source

pub async fn consume(&mut self, consume: bool) -> Result<(), Error>

Source

pub async fn play(&mut self) -> Result<(), Error>

Source

pub async fn playid(&mut self, id: u32) -> Result<(), Error>

Source

pub async fn pause(&mut self) -> Result<(), Error>

Source

pub async fn play_pause(&mut self, play: bool) -> Result<(), Error>

Source

pub async fn next(&mut self) -> Result<(), Error>

Source

pub async fn prev(&mut self) -> Result<(), Error>

Source

pub async fn stop(&mut self) -> Result<(), Error>

Source

pub async fn listall( &mut self, path: Option<&str>, ) -> Result<ListallResponse, Error>

Source

pub async fn listallinfo( &mut self, path: Option<&str>, ) -> Result<ListallinfoResponse, Error>

Source

pub async fn queue_add(&mut self, path: &str) -> Result<(), Error>

Source

pub async fn queue_clear(&mut self) -> Result<(), Error>

Source

pub async fn queue(&mut self) -> Result<Vec<Track>, Error>

Source

pub async fn search(&mut self, filter: &Filter) -> Result<Vec<Track>, Error>

§Example
use async_mpd::{MpdClient, Error, Tag, Filter, ToFilterExpr};

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

    let mut filter = Filter::new()
        .and(Tag::Artist.equals("The Beatles"))
        .and(Tag::Album.contains("White"));

    let res = mpd.search(&filter).await?;
    println!("{:?}", res);

    Ok(())
}
Source

pub async fn exec_wrapped<C>( &mut self, cmd: C, ) -> Result<WrappedResponse, Error>
where C: MpdCmd,

Execute a Mpd Command. Returns a enum wrapped Response

Source

pub async fn exec<C>( &mut self, cmd: C, ) -> Result<<C::Handler as ResponseHandler>::Response, Error>
where C: MpdCmd,

Execute a Mpd Command, get back the matching Response

Trait Implementations§

Source§

impl Default for MpdClient

Source§

fn default() -> MpdClient

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.