pub struct Client<S = TcpStream>{
pub version: Version,
/* private fields */
}
Expand description
Client connection
Fields§
§version: Version
MPD protocol version
Implementations§
Source§impl<S: Read + Write> Client<S>
impl<S: Read + Write> Client<S>
Sourcepub fn new(socket: S) -> Result<Client<S>>
pub fn new(socket: S) -> Result<Client<S>>
Create client from some arbitrary pre-connected socket
Sourcepub fn clearerror(&mut self) -> Result<()>
pub fn clearerror(&mut self) -> Result<()>
Clear error state
Sourcepub fn crossfade<T: ToSeconds>(&mut self, value: T) -> Result<()>
pub fn crossfade<T: ToSeconds>(&mut self, value: T) -> Result<()>
Set crossfade time in seconds
Sourcepub fn mixrampdelay<T: ToSeconds>(&mut self, value: T) -> Result<()>
pub fn mixrampdelay<T: ToSeconds>(&mut self, value: T) -> Result<()>
Set mixramp delay in seconds
Sourcepub fn replaygain(&mut self, gain: ReplayGain) -> Result<()>
pub fn replaygain(&mut self, gain: ReplayGain) -> Result<()>
Set replay gain mode
Sourcepub fn switch<T: ToQueuePlace>(&mut self, place: T) -> Result<()>
pub fn switch<T: ToQueuePlace>(&mut self, place: T) -> Result<()>
Start playback from given song in a queue
Sourcepub fn toggle_pause(&mut self) -> Result<()>
pub fn toggle_pause(&mut self) -> Result<()>
Toggle pause state
Sourcepub fn seek<T: ToSeconds, P: ToQueuePlace>(
&mut self,
place: P,
pos: T,
) -> Result<()>
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
Sourcepub fn rewind<T: ToSeconds>(&mut self, pos: T) -> Result<()>
pub fn rewind<T: ToSeconds>(&mut self, pos: T) -> Result<()>
Seek to a given place (in seconds) in the current song
Sourcepub fn songs<T: ToQueueRangeOrPlace>(&mut self, pos: T) -> Result<Vec<Song>>
pub fn songs<T: ToQueueRangeOrPlace>(&mut self, pos: T) -> Result<Vec<Song>>
List given song or range of songs in a play queue
Sourcepub fn currentsong(&mut self) -> Result<Option<Song>>
pub fn currentsong(&mut self) -> Result<Option<Song>>
Get current playing song
Sourcepub fn playlistid(&mut self, id: Id) -> Result<Option<Song>>
pub fn playlistid(&mut self, id: Id) -> Result<Option<Song>>
gets the song wrt to songid in the playlist
Sourcepub fn changes(&mut self, version: u32) -> Result<Vec<Song>>
pub fn changes(&mut self, version: u32) -> Result<Vec<Song>>
List all changes in a queue since given version
Sourcepub fn insert<P: ToSongPath>(&mut self, path: P, pos: usize) -> Result<usize>
pub fn insert<P: ToSongPath>(&mut self, path: P, pos: usize) -> Result<usize>
Insert a song into a given position in a queue
Sourcepub fn delete<T: ToQueueRangeOrPlace>(&mut self, pos: T) -> Result<()>
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
Sourcepub fn shift<T: ToQueueRangeOrPlace>(
&mut self,
from: T,
to: usize,
) -> Result<()>
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
Sourcepub fn shuffle<T: ToQueueRange>(&mut self, range: T) -> Result<()>
pub fn shuffle<T: ToQueueRange>(&mut self, range: T) -> Result<()>
Shuffle queue in a given range (use ..
to shuffle full queue)
Sourcepub fn priority<T: ToQueueRangeOrPlace>(
&mut self,
pos: T,
prio: u8,
) -> Result<()>
pub fn priority<T: ToQueueRangeOrPlace>( &mut self, pos: T, prio: u8, ) -> Result<()>
Set song priority in a queue
Sourcepub fn range<T: ToSongId, R: ToSongRange>(
&mut self,
song: T,
range: R,
) -> Result<()>
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.
Sourcepub fn tag<T: ToSongId>(
&mut self,
song: T,
tag: &str,
value: &str,
) -> Result<()>
pub fn tag<T: ToSongId>( &mut self, song: T, tag: &str, value: &str, ) -> Result<()>
Add tag to a song
Sourcepub fn playlist<N: ToPlaylistName>(&mut self, name: N) -> Result<Vec<Song>>
pub fn playlist<N: ToPlaylistName>(&mut self, name: N) -> Result<Vec<Song>>
List all songs in a playlist
Sourcepub fn load<T: ToQueueRange, N: ToPlaylistName>(
&mut self,
name: N,
range: T,
) -> Result<()>
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.
Sourcepub fn save<N: ToPlaylistName>(&mut self, name: N) -> Result<()>
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.
Sourcepub fn pl_rename<N: ToPlaylistName>(
&mut self,
name: N,
newname: &str,
) -> Result<()>
pub fn pl_rename<N: ToPlaylistName>( &mut self, name: N, newname: &str, ) -> Result<()>
Rename playlist
Sourcepub fn pl_push<N: ToPlaylistName, P: ToSongPath>(
&mut self,
name: N,
path: P,
) -> Result<()>
pub fn pl_push<N: ToPlaylistName, P: ToSongPath>( &mut self, name: N, path: P, ) -> Result<()>
Add new songs to a playlist
Sourcepub fn pl_delete<N: ToPlaylistName>(&mut self, name: N, pos: u32) -> Result<()>
pub fn pl_delete<N: ToPlaylistName>(&mut self, name: N, pos: u32) -> Result<()>
Delete a song at a given position in a playlist
Sourcepub fn pl_shift<N: ToPlaylistName>(
&mut self,
name: N,
from: u32,
to: u32,
) -> Result<()>
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
Sourcepub fn rescan(&mut self) -> Result<u32>
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
Sourcepub fn update(&mut self) -> Result<u32>
pub fn update(&mut self) -> Result<u32>
Run database update, i.e. remove non-existing files from DB
Sourcepub fn listfiles(&mut self, song_path: &str) -> Result<Vec<(String, String)>>
pub fn listfiles(&mut self, song_path: &str) -> Result<Vec<(String, String)>>
List all songs/directories in directory
Sourcepub fn find<W>(&mut self, query: &Query<'_>, window: W) -> Result<Vec<Song>>
pub fn find<W>(&mut self, query: &Query<'_>, window: W) -> Result<Vec<Song>>
Find songs matching Query conditions.
Sourcepub fn search<W>(&mut self, query: &Query<'_>, window: W) -> Result<Vec<Song>>
pub fn search<W>(&mut self, query: &Query<'_>, window: W) -> Result<Vec<Song>>
Case-insensitively search for songs matching Query conditions.
Sourcepub fn list(
&mut self,
term: &Term<'_>,
query: &Query<'_>,
) -> Result<Vec<String>>
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.
Sourcepub fn findadd(&mut self, query: &Query<'_>) -> Result<()>
pub fn findadd(&mut self, query: &Query<'_>) -> Result<()>
Find all songs in the db that match query and adds them to current playlist.
Sourcepub fn lsinfo<P: ToSongPath>(&mut self, path: P) -> Result<Vec<Song>>
pub fn lsinfo<P: ToSongPath>(&mut self, path: P) -> Result<Vec<Song>>
Lists the contents of a directory.
Sourcepub fn readcomments<P: ToSongPath>(
&mut self,
path: P,
) -> Result<impl Iterator<Item = Result<(String, String)>> + '_>
pub fn readcomments<P: ToSongPath>( &mut self, path: P, ) -> Result<impl Iterator<Item = Result<(String, String)>> + '_>
Returns raw metadata for file
Sourcepub fn output<T: ToOutputId>(&mut self, id: T, state: bool) -> Result<()>
pub fn output<T: ToOutputId>(&mut self, id: T, state: bool) -> Result<()>
Set given output enabled state
Sourcepub fn out_disable<T: ToOutputId>(&mut self, id: T) -> Result<()>
pub fn out_disable<T: ToOutputId>(&mut self, id: T) -> Result<()>
Disable given output
Sourcepub fn out_enable<T: ToOutputId>(&mut self, id: T) -> Result<()>
pub fn out_enable<T: ToOutputId>(&mut self, id: T) -> Result<()>
Enable given output
Sourcepub fn out_toggle<T: ToOutputId>(&mut self, id: T) -> Result<()>
pub fn out_toggle<T: ToOutputId>(&mut self, id: T) -> Result<()>
Toggle given output
Sourcepub fn music_directory(&mut self) -> Result<String>
pub fn music_directory(&mut self) -> Result<String>
Get current music directory
Sourcepub fn notcommands(&mut self) -> Result<Vec<String>>
pub fn notcommands(&mut self) -> Result<Vec<String>>
List all forbidden commands
Sourcepub fn urlhandlers(&mut self) -> Result<Vec<String>>
pub fn urlhandlers(&mut self) -> Result<Vec<String>>
List all available URL handlers
Sourcepub fn channels(&mut self) -> Result<Vec<Channel>>
pub fn channels(&mut self) -> Result<Vec<Channel>>
List all channels available for current connection
Sourcepub fn readmessages(&mut self) -> Result<Vec<Message>>
pub fn readmessages(&mut self) -> Result<Vec<Message>>
Read queued messages from subscribed channels
Sourcepub fn sendmessage(&mut self, channel: Channel, message: &str) -> Result<()>
pub fn sendmessage(&mut self, channel: Channel, message: &str) -> Result<()>
Send a message to a channel
Sourcepub fn unsubscribe(&mut self, channel: Channel) -> Result<()>
pub fn unsubscribe(&mut self, channel: Channel) -> Result<()>
Unsubscribe to a channel
Sourcepub fn mounts(&mut self) -> Result<Vec<Mount>>
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.
Sourcepub fn neighbors(&mut self) -> Result<Vec<Neighbor>>
pub fn neighbors(&mut self) -> Result<Vec<Neighbor>>
List all network neighbors, which can be potentially mounted
Sourcepub fn mount(&mut self, path: &str, uri: &str) -> Result<()>
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.
Sourcepub fn unmount(&mut self, path: &str) -> Result<()>
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.
Sourcepub fn sticker(&mut self, typ: &str, uri: &str, name: &str) -> Result<String>
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
Sourcepub fn set_sticker(
&mut self,
typ: &str,
uri: &str,
name: &str,
value: &str,
) -> Result<()>
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
Sourcepub fn delete_sticker(&mut self, typ: &str, uri: &str, name: &str) -> Result<()>
pub fn delete_sticker(&mut self, typ: &str, uri: &str, name: &str) -> Result<()>
Delete sticker from a given object, identified by type and uri
Sourcepub fn clear_stickers(&mut self, typ: &str, uri: &str) -> Result<()>
pub fn clear_stickers(&mut self, typ: &str, uri: &str) -> Result<()>
Remove all stickers from a given object, identified by type and uri
Sourcepub fn stickers(&mut self, typ: &str, uri: &str) -> Result<Vec<String>>
pub fn stickers(&mut self, typ: &str, uri: &str) -> Result<Vec<String>>
List all stickers from a given object, identified by type and uri
Sourcepub fn stickers_map(
&mut self,
typ: &str,
uri: &str,
) -> Result<HashMap<String, String>>
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