@@ -209,13 +209,13 @@ impl<S: Read + Write> Client<S> {
209
209
"playlistinfo"
210
210
} ;
211
211
self . run_command ( command, pos. to_range ( ) )
212
- . and_then ( |_| self . read_pairs ( ) . split ( "file" ) . map ( |v| v . and_then ( FromMap :: from_map ) ) . collect ( ) )
212
+ . and_then ( |_| self . read_structs ( "file" ) )
213
213
}
214
214
215
215
/// List all songs in a play queue
216
216
pub fn queue ( & mut self ) -> Result < Vec < Song > > {
217
217
self . run_command ( "playlistinfo" , ( ) )
218
- . and_then ( |_| self . read_pairs ( ) . split ( "file" ) . map ( |v| v . and_then ( FromMap :: from_map ) ) . collect ( ) )
218
+ . and_then ( |_| self . read_structs ( "file" ) )
219
219
}
220
220
221
221
/// Get current playing song
@@ -233,7 +233,7 @@ impl<S: Read + Write> Client<S> {
233
233
/// List all changes in a queue since given version
234
234
pub fn changes ( & mut self , version : u32 ) -> Result < Vec < Song > > {
235
235
self . run_command ( "plchanges" , version)
236
- . and_then ( |_| self . read_pairs ( ) . split ( "file" ) . map ( |v| v . and_then ( FromMap :: from_map ) ) . collect ( ) )
236
+ . and_then ( |_| self . read_structs ( "file" ) )
237
237
}
238
238
239
239
/// Append a song into a queue
@@ -338,13 +338,13 @@ impl<S: Read + Write> Client<S> {
338
338
/// List all playlists
339
339
pub fn playlists ( & mut self ) -> Result < Vec < Playlist > > {
340
340
self . run_command ( "listplaylists" , ( ) )
341
- . and_then ( |_| self . read_pairs ( ) . split ( "playlist" ) . map ( |v| v . and_then ( FromMap :: from_map ) ) . collect ( ) )
341
+ . and_then ( |_| self . read_structs ( "playlist" ) )
342
342
}
343
343
344
344
/// List all songs in a playlist
345
345
pub fn playlist < N : ToPlaylistName > ( & mut self , name : N ) -> Result < Vec < Song > > {
346
346
self . run_command ( "listplaylistinfo" , name. to_name ( ) )
347
- . and_then ( |_| self . read_pairs ( ) . split ( "file" ) . map ( |v| v . and_then ( FromMap :: from_map ) ) . collect ( ) )
347
+ . and_then ( |_| self . read_structs ( "file" ) )
348
348
}
349
349
350
350
/// Load playlist into queue
@@ -447,12 +447,7 @@ impl<S: Read + Write> Client<S> {
447
447
448
448
fn find_generic ( & mut self , cmd : & str , query : & Query , window : Window ) -> Result < Vec < Song > > {
449
449
self . run_command ( cmd, ( query, window) )
450
- . and_then ( |_| {
451
- self . read_pairs ( )
452
- . split ( "file" )
453
- . map ( |v| v. and_then ( FromMap :: from_map) )
454
- . collect ( )
455
- } )
450
+ . and_then ( |_| self . read_structs ( "file" ) )
456
451
}
457
452
458
453
// }}}
@@ -461,7 +456,7 @@ impl<S: Read + Write> Client<S> {
461
456
/// List all outputs
462
457
pub fn outputs ( & mut self ) -> Result < Vec < Output > > {
463
458
self . run_command ( "outputs" , ( ) )
464
- . and_then ( |_| self . read_pairs ( ) . split ( "outputid" ) . map ( |v| v . and_then ( FromMap :: from_map ) ) . collect ( ) )
459
+ . and_then ( |_| self . read_structs ( "outputid" ) )
465
460
}
466
461
467
462
/// Set given output enabled state
@@ -611,7 +606,7 @@ impl<S: Read + Write> Client<S> {
611
606
/// Read queued messages from subscribed channels
612
607
pub fn readmessages ( & mut self ) -> Result < Vec < Message > > {
613
608
self . run_command ( "readmessages" , ( ) )
614
- . and_then ( |_| self . read_pairs ( ) . split ( "channel" ) . map ( |v| v . and_then ( FromMap :: from_map ) ) . collect ( ) )
609
+ . and_then ( |_| self . read_structs ( "channel" ) )
615
610
}
616
611
617
612
/// Send a message to a channel
@@ -639,13 +634,13 @@ impl<S: Read + Write> Client<S> {
639
634
/// These mounts exist inside MPD process only, thus they can work without root permissions.
640
635
pub fn mounts ( & mut self ) -> Result < Vec < Mount > > {
641
636
self . run_command ( "listmounts" , ( ) )
642
- . and_then ( |_| self . read_pairs ( ) . split ( "mount" ) . map ( |v| v . and_then ( FromMap :: from_map ) ) . collect ( ) )
637
+ . and_then ( |_| self . read_structs ( "mount" ) )
643
638
}
644
639
645
640
/// List all network neighbors, which can be potentially mounted
646
641
pub fn neighbors ( & mut self ) -> Result < Vec < Neighbor > > {
647
642
self . run_command ( "listneighbors" , ( ) )
648
- . and_then ( |_| self . read_pairs ( ) . split ( "neighbor" ) . map ( |v| v . and_then ( FromMap :: from_map ) ) . collect ( ) )
643
+ . and_then ( |_| self . read_structs ( "neighbor" ) )
649
644
}
650
645
651
646
/// Mount given neighbor to a mount point
0 commit comments