Client

Struct Client 

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

General-purpose mpd client: “general-purpose” in the sense that we send commands through it; the interface is narrowly scoped to this program’s needs.

§Introduction

This is the primary abstraction of the MPD client protocol, written for the convenience of mpdpopm. Construct instances with a TCP socket, a Unix socket, or any RequestResponse implementation. You can then carry out assorted operations in the MPD client protocol by invoking its methods.

use std::path::Path;
use mpdpopm::clients::Client;
let client = Client::open(Path::new("/var/run/mpd.sock"));

client is now a Future that resolves to a Client instance talking to /var/run/mpd.sock.

use mpdpopm::clients::Client;
let client = Client::connect("localhost:6600");

client is now a Future that resolves to a Client instance talking TCP to the MPD server on localhost at port 6600.

Implementations§

Source§

impl Client

Source

pub async fn connect<A: ToSocketAddrs>(addrs: A) -> Result<Client>

Source

pub async fn open<P: AsRef<Path>>(pth: P) -> Result<Client>

Source

pub fn new(stream: Box<dyn RequestResponse>) -> Result<Client>

Source§

impl Client

Source

pub async fn status(&mut self) -> Result<PlayerStatus>

Retrieve the current server status.

Source

pub async fn get_sticker<T: FromStr>( &mut self, file: &str, sticker_name: &str, ) -> Result<Option<T>>
where <T as FromStr>::Err: Error + Sync + Send + 'static,

Retrieve a song sticker by name

Source

pub async fn set_sticker<T: Display>( &mut self, file: &str, sticker_name: &str, sticker_value: &T, ) -> Result<()>

Set a song sticker by name

Source

pub async fn send_to_playlist(&mut self, file: &str, pl: &str) -> Result<()>

Send a file to a playlist

Source

pub async fn send_message(&mut self, chan: &str, msg: &str) -> Result<()>

Send an arbitrary message

Source

pub async fn update(&mut self, uri: &str) -> Result<u64>

Update a URI

Source

pub async fn get_stored_playlists(&mut self) -> Result<Vec<String>>

Get the list of stored playlists

Source

pub async fn find1( &mut self, cond: &str, val: &str, case: bool, ) -> Result<Vec<String>>

Search the database for songs matching filter (unary operator)

Set case to true to request a case-sensitive search (false yields case-insensitive)

Source

pub async fn find2( &mut self, attr: &str, op: &str, val: &str, case: bool, ) -> Result<Vec<String>>

Search the database for songs matching filter (case-sensitive, binary operator)

Set case to true to request a case-sensitive search (false yields case-insensitive)

Source

pub async fn get_stickers( &mut self, sticker: &str, ) -> Result<HashMap<String, String>>

Retrieve all instances of a given sticker under the music directory

Return a mapping from song URI to textual sticker value

Source

pub async fn get_all_songs(&mut self) -> Result<Vec<String>>

Retrieve the song URIs of all songs in the database

Returns a vector of String

Source

pub async fn add(&mut self, uri: &str) -> Result<()>

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl !Send for Client

§

impl !Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more