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<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>>where
W: Into<Window>,
pub fn find<W>(&mut self, query: &Query<'_>, window: W) -> Result<Vec<Song>>where W: Into<Window>,
Find songs matching Query conditions.
sourcepub fn search<W>(&mut self, query: &Query<'_>, window: W) -> Result<Vec<Song>>where
W: Into<Window>,
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.
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