@@ -15,7 +15,7 @@ use output::Output;
1515use playlist:: Playlist ;
1616use plugin:: Plugin ;
1717use proto:: * ;
18- use search:: { Query , Window } ;
18+ use search:: { Query , Window , Term } ;
1919use song:: { Id , Song } ;
2020use stats:: Stats ;
2121use status:: { ReplayGain , Status } ;
@@ -238,15 +238,15 @@ impl<S: Read + Write> Client<S> {
238238 }
239239
240240 /// Append a song into a queue
241- pub fn push < P : AsRef < str > > ( & mut self , path : P ) -> Result < Id > {
242- self . run_command ( "addid" , path. as_ref ( ) )
241+ pub fn push < P : ToSongPath > ( & mut self , path : P ) -> Result < Id > {
242+ self . run_command ( "addid" , path)
243243 . and_then ( |_| self . read_field ( "Id" ) )
244244 . map ( Id )
245245 }
246246
247247 /// Insert a song into a given position in a queue
248- pub fn insert < P : AsRef < str > > ( & mut self , path : P , pos : usize ) -> Result < usize > {
249- self . run_command ( "addid" , ( path. as_ref ( ) , pos) )
248+ pub fn insert < P : ToSongPath > ( & mut self , path : P , pos : usize ) -> Result < usize > {
249+ self . run_command ( "addid" , ( path, pos) )
250250 . and_then ( |_| self . read_field ( "Id" ) )
251251 }
252252
@@ -377,8 +377,8 @@ impl<S: Read + Write> Client<S> {
377377 }
378378
379379 /// Add new songs to a playlist
380- pub fn pl_push < N : ToPlaylistName , P : AsRef < str > > ( & mut self , name : N , path : P ) -> Result < ( ) > {
381- self . run_command ( "playlistadd" , ( name. to_name ( ) , path. as_ref ( ) ) )
380+ pub fn pl_push < N : ToPlaylistName , P : ToSongPath > ( & mut self , name : N , path : P ) -> Result < ( ) > {
381+ self . run_command ( "playlistadd" , ( name. to_name ( ) , path) )
382382 . and_then ( |_| self . expect_ok ( ) )
383383 }
384384
@@ -413,7 +413,7 @@ impl<S: Read + Write> Client<S> {
413413 // Database search {{{
414414 // TODO: count tag needle [...] [group] [grouptag], find type what [...] [window start:end]
415415 // TODO: search type what [...] [window start:end], searchadd type what [...]
416- // TODO: findadd type what [...], listallinfo [uri], listfiles [uri], lsinfo [uri]
416+ // TODO: listallinfo [uri], listfiles [uri]
417417 // TODO: list type [filtertype] [filterwhat] [...] [group] [grouptype] [...]
418418 // TODO: searchaddpl name type what [...], readcomments
419419
@@ -436,6 +436,26 @@ impl<S: Read + Write> Client<S> {
436436 . and_then ( |_| self . read_structs ( "file" ) )
437437 }
438438
439+ /// Lists unique tags values of the specified type for songs matching the given query.
440+ // TODO: list type [filtertype] [filterwhat] [...] [group] [grouptype] [...]
441+ // It isn't clear if or how `group` works
442+ pub fn list ( & mut self , term : & Term , query : & Query ) -> Result < Vec < String > > {
443+ self . run_command ( "list" , ( term, query) )
444+ . and_then ( |_| self . read_pairs ( ) . map ( |p| p. map ( |p| p. 1 ) ) . collect ( ) )
445+ }
446+
447+ /// Find all songs in the db that match query and adds them to current playlist.
448+ pub fn findadd ( & mut self , query : & Query ) -> Result < ( ) > {
449+ self . run_command ( "findadd" , query)
450+ . and_then ( |_| self . expect_ok ( ) )
451+ }
452+
453+ /// Lists the contents of a directory.
454+ pub fn lsinfo < P : ToSongPath > ( & mut self , path : P ) -> Result < Song > {
455+ self . run_command ( "lsinfo" , path)
456+ . and_then ( |_| self . read_struct ( ) )
457+ }
458+
439459 // }}}
440460
441461 // Output methods {{{
0 commit comments