Struct mpd::client::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>

§

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> 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.