Struct Client

Source
pub struct Client<S = TcpStream>
where S: Read + Write,
{ pub version: Version, /* private fields */ }
Expand description

Client connection

Fields§

§version: Version

MPD protocol version

Implementations§

Source§

impl Client<TcpStream>

Source

pub fn connect<A: ToSocketAddrs>(addr: A) -> Result<Client<TcpStream>>

Connect client to some IP address

Source§

impl<S: Read + Write> Client<S>

Source

pub fn new(socket: S) -> Result<Client<S>>

Create client from some arbitrary pre-connected socket

Source

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

Get MPD status

Source

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

Get MPD playing statistics

Source

pub fn clearerror(&mut self) -> Result<()>

Clear error state

Source

pub fn volume(&mut self, volume: i8) -> Result<()>

Set volume

Source

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

Set repeat state

Source

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

Set random state

Source

pub fn single(&mut self, value: bool) -> Result<()>

Set single state

Source

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

Set consume state

Source

pub fn crossfade<T: ToSeconds>(&mut self, value: T) -> Result<()>

Set crossfade time in seconds

Source

pub fn mixrampdb(&mut self, value: f32) -> Result<()>

Set mixramp level in dB

Source

pub fn mixrampdelay<T: ToSeconds>(&mut self, value: T) -> Result<()>

Set mixramp delay in seconds

Source

pub fn replaygain(&mut self, gain: ReplayGain) -> Result<()>

Set replay gain mode

Source

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

Start playback

Source

pub fn switch<T: ToQueuePlace>(&mut self, place: T) -> Result<()>

Start playback from given song in a queue

Source

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

Switch to a next song in queue

Source

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

Switch to a previous song in queue

Source

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

Stop playback

Source

pub fn toggle_pause(&mut self) -> Result<()>

Toggle pause state

Source

pub fn pause(&mut self, value: bool) -> Result<()>

Set pause state

Source

pub fn seek<T: ToSeconds, P: ToQueuePlace>( &mut self, place: P, pos: T, ) -> Result<()>

Seek to a given place (in seconds) in a given song

Source

pub fn rewind<T: ToSeconds>(&mut self, pos: T) -> Result<()>

Seek to a given place (in seconds) in the current song

Source

pub fn songs<T: ToQueueRangeOrPlace>(&mut self, pos: T) -> Result<Vec<Song>>

List given song or range of songs in a play queue

Source

pub fn queue(&mut self) -> Result<Vec<Song>>

List all songs in a play queue

Source

pub fn listall(&mut self) -> Result<Vec<Song>>

lists all songs in the database

Source

pub fn currentsong(&mut self) -> Result<Option<Song>>

Get current playing song

Source

pub fn playlistid(&mut self, id: Id) -> Result<Option<Song>>

gets the song wrt to songid in the playlist

Source

pub fn clear(&mut self) -> Result<()>

Clear current queue

Source

pub fn changes(&mut self, version: u32) -> Result<Vec<Song>>

List all changes in a queue since given version

Source

pub fn push<P: ToSongPath>(&mut self, path: P) -> Result<Id>

Append a song into a queue

Source

pub fn insert<P: ToSongPath>(&mut self, path: P, pos: usize) -> Result<usize>

Insert a song into a given position in a queue

Source

pub fn delete<T: ToQueueRangeOrPlace>(&mut self, pos: T) -> Result<()>

Delete a song (at some position) or several songs (in a range) from a queue

Source

pub fn shift<T: ToQueueRangeOrPlace>( &mut self, from: T, to: usize, ) -> Result<()>

Move a song (at a some position) or several songs (in a range) to other position in queue

Source

pub fn swap<T: ToQueuePlace>(&mut self, one: T, two: T) -> Result<()>

Swap to songs in a queue

Source

pub fn shuffle<T: ToQueueRange>(&mut self, range: T) -> Result<()>

Shuffle queue in a given range (use .. to shuffle full queue)

Source

pub fn priority<T: ToQueueRangeOrPlace>( &mut self, pos: T, prio: u8, ) -> Result<()>

Set song priority in a queue

Source

pub fn range<T: ToSongId, R: ToSongRange>( &mut self, song: T, range: R, ) -> Result<()>

Set song range (in seconds) to play

Doesn’t work for currently playing song.

Source

pub fn tag<T: ToSongId>( &mut self, song: T, tag: &str, value: &str, ) -> Result<()>

Add tag to a song

Source

pub fn untag<T: ToSongId>(&mut self, song: T, tag: &str) -> Result<()>

Delete tag from a song

Source

pub fn ping(&mut self) -> Result<()>

Just pings MPD server, does nothing

Source

pub fn close(&mut self) -> Result<()>

Close MPD connection

Source

pub fn kill(&mut self) -> Result<()>

Kill MPD server

Source

pub fn login(&mut self, password: &str) -> Result<()>

Login to MPD server with given password

Source

pub fn playlists(&mut self) -> Result<Vec<Playlist>>

List all playlists

Source

pub fn playlist<N: ToPlaylistName>(&mut self, name: N) -> Result<Vec<Song>>

List all songs in a playlist

Source

pub fn load<T: ToQueueRange, N: ToPlaylistName>( &mut self, name: N, range: T, ) -> Result<()>

Load playlist into queue

You can give either full range (..) to load all songs in a playlist, or some partial range to load only part of playlist.

Source

pub fn save<N: ToPlaylistName>(&mut self, name: N) -> Result<()>

Save current queue into playlist

If playlist with given name doesn’t exist, create new one.

Source

pub fn pl_rename<N: ToPlaylistName>( &mut self, name: N, newname: &str, ) -> Result<()>

Rename playlist

Source

pub fn pl_clear<N: ToPlaylistName>(&mut self, name: N) -> Result<()>

Clear playlist

Source

pub fn pl_remove<N: ToPlaylistName>(&mut self, name: N) -> Result<()>

Delete playlist

Source

pub fn pl_push<N: ToPlaylistName, P: ToSongPath>( &mut self, name: N, path: P, ) -> Result<()>

Add new songs to a playlist

Source

pub fn pl_delete<N: ToPlaylistName>(&mut self, name: N, pos: u32) -> Result<()>

Delete a song at a given position in a playlist

Source

pub fn pl_shift<N: ToPlaylistName>( &mut self, name: N, from: u32, to: u32, ) -> Result<()>

Move song in a playlist from one position into another

Source

pub fn rescan(&mut self) -> Result<u32>

Run database rescan, i.e. remove non-existing files from DB as well as add new files to DB

Source

pub fn update(&mut self) -> Result<u32>

Run database update, i.e. remove non-existing files from DB

Source

pub fn listfiles(&mut self, song_path: &str) -> Result<Vec<(String, String)>>

List all songs/directories in directory

Source

pub fn find<W>(&mut self, query: &Query<'_>, window: W) -> Result<Vec<Song>>
where W: Into<Window>,

Find songs matching Query conditions.

Source

pub fn albumart<P: ToSongPath>(&mut self, path: &P) -> Result<Vec<u8>>

Find album art for file

Source

pub fn search<W>(&mut self, query: &Query<'_>, window: W) -> Result<Vec<Song>>
where W: Into<Window>,

Case-insensitively search for songs matching Query conditions.

Source

pub fn list( &mut self, term: &Term<'_>, query: &Query<'_>, ) -> Result<Vec<String>>

Lists unique tags values of the specified type for songs matching the given query.

Source

pub fn findadd(&mut self, query: &Query<'_>) -> Result<()>

Find all songs in the db that match query and adds them to current playlist.

Source

pub fn lsinfo<P: ToSongPath>(&mut self, path: P) -> Result<Vec<Song>>

Lists the contents of a directory.

Source

pub fn readcomments<P: ToSongPath>( &mut self, path: P, ) -> Result<impl Iterator<Item = Result<(String, String)>> + '_>

Returns raw metadata for file

Source

pub fn outputs(&mut self) -> Result<Vec<Output>>

List all outputs

Source

pub fn output<T: ToOutputId>(&mut self, id: T, state: bool) -> Result<()>

Set given output enabled state

Source

pub fn out_disable<T: ToOutputId>(&mut self, id: T) -> Result<()>

Disable given output

Source

pub fn out_enable<T: ToOutputId>(&mut self, id: T) -> Result<()>

Enable given output

Source

pub fn out_toggle<T: ToOutputId>(&mut self, id: T) -> Result<()>

Toggle given output

Source

pub fn music_directory(&mut self) -> Result<String>

Get current music directory

Source

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

List all available commands

Source

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

List all forbidden commands

Source

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

List all available URL handlers

Source

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

List all supported tag types

Source

pub fn decoders(&mut self) -> Result<Vec<Plugin>>

List all available decoder plugins

Source

pub fn channels(&mut self) -> Result<Vec<Channel>>

List all channels available for current connection

Source

pub fn readmessages(&mut self) -> Result<Vec<Message>>

Read queued messages from subscribed channels

Source

pub fn sendmessage(&mut self, channel: Channel, message: &str) -> Result<()>

Send a message to a channel

Source

pub fn subscribe(&mut self, channel: Channel) -> Result<()>

Subscribe to a channel

Source

pub fn unsubscribe(&mut self, channel: Channel) -> Result<()>

Unsubscribe to a channel

Source

pub fn mounts(&mut self) -> Result<Vec<Mount>>

List all (virtual) mounts

These mounts exist inside MPD process only, thus they can work without root permissions.

Source

pub fn neighbors(&mut self) -> Result<Vec<Neighbor>>

List all network neighbors, which can be potentially mounted

Source

pub fn mount(&mut self, path: &str, uri: &str) -> Result<()>

Mount given neighbor to a mount point

The mount exists inside MPD process only, thus it can work without root permissions.

Source

pub fn unmount(&mut self, path: &str) -> Result<()>

Unmount given active (virtual) mount

The mount exists inside MPD process only, thus it can work without root permissions.

Source

pub fn sticker(&mut self, typ: &str, uri: &str, name: &str) -> Result<String>

Show sticker value for a given object, identified by type and uri

Source

pub fn set_sticker( &mut self, typ: &str, uri: &str, name: &str, value: &str, ) -> Result<()>

Set sticker value for a given object, identified by type and uri

Source

pub fn delete_sticker(&mut self, typ: &str, uri: &str, name: &str) -> Result<()>

Delete sticker from a given object, identified by type and uri

Source

pub fn clear_stickers(&mut self, typ: &str, uri: &str) -> Result<()>

Remove all stickers from a given object, identified by type and uri

Source

pub fn stickers(&mut self, typ: &str, uri: &str) -> Result<Vec<String>>

List all stickers from a given object, identified by type and uri

Source

pub fn stickers_map( &mut self, typ: &str, uri: &str, ) -> Result<HashMap<String, String>>

List all stickers from a given object in a map, identified by type and uri

Source

pub fn find_sticker( &mut self, typ: &str, uri: &str, name: &str, ) -> Result<Vec<(String, String)>>

List all (file, sticker) pairs for sticker name and objects of given type from given directory (identified by uri)

Source

pub fn find_sticker_eq( &mut self, typ: &str, uri: &str, name: &str, value: &str, ) -> Result<Vec<String>>

List all files of a given type under given directory (identified by uri) with a tag set to given value

Trait Implementations§

Source§

impl<S> Debug for Client<S>
where S: Read + Write + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Client<TcpStream>

Source§

fn default() -> Client<TcpStream>

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

impl<S: Read + Write> Idle for Client<S>

Source§

type Stream = S

Stream type of a client
Source§

fn idle<'a>( &'a mut self, subsystems: &[Subsystem], ) -> Result<IdleGuard<'a, S>, Error>

Start listening for events from a set of subsystems Read more
Source§

fn wait(&mut self, subsystems: &[Subsystem]) -> Result<Vec<Subsystem>, Error>

Wait for events from a set of subsystems and return list of affected subsystems Read more

Auto Trait Implementations§

§

impl<S> Freeze for Client<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Client<S>
where S: RefUnwindSafe,

§

impl<S> Send for Client<S>
where S: Send,

§

impl<S> Sync for Client<S>
where S: Sync,

§

impl<S> Unpin for Client<S>
where S: Unpin,

§

impl<S> UnwindSafe for Client<S>
where S: UnwindSafe,

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, 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.