@@ -482,61 +482,25 @@ impl<S: Read + Write> Client<S> {
482
482
/// List all available commands
483
483
pub fn commands ( & mut self ) -> Result < Vec < String > > {
484
484
self . run_command ( "commands" , ( ) )
485
- . and_then ( |_| {
486
- self . read_pairs ( )
487
- . filter ( |r| {
488
- r. as_ref ( )
489
- . map ( |& ( ref a, _) | * a == "command" )
490
- . unwrap_or ( true )
491
- } )
492
- . map ( |r| r. map ( |( _, b) | b) )
493
- . collect ( )
494
- } )
485
+ . and_then ( |_| self . read_list ( "command" ) )
495
486
}
496
487
497
488
/// List all forbidden commands
498
489
pub fn notcommands ( & mut self ) -> Result < Vec < String > > {
499
490
self . run_command ( "notcommands" , ( ) )
500
- . and_then ( |_| {
501
- self . read_pairs ( )
502
- . filter ( |r| {
503
- r. as_ref ( )
504
- . map ( |& ( ref a, _) | * a == "command" )
505
- . unwrap_or ( true )
506
- } )
507
- . map ( |r| r. map ( |( _, b) | b) )
508
- . collect ( )
509
- } )
491
+ . and_then ( |_| self . read_list ( "command" ) )
510
492
}
511
493
512
494
/// List all available URL handlers
513
495
pub fn urlhandlers ( & mut self ) -> Result < Vec < String > > {
514
496
self . run_command ( "urlhandlers" , ( ) )
515
- . and_then ( |_| {
516
- self . read_pairs ( )
517
- . filter ( |r| {
518
- r. as_ref ( )
519
- . map ( |& ( ref a, _) | * a == "handler" )
520
- . unwrap_or ( true )
521
- } )
522
- . map ( |r| r. map ( |( _, b) | b) )
523
- . collect ( )
524
- } )
497
+ . and_then ( |_| self . read_list ( "handler" ) )
525
498
}
526
499
527
500
/// List all supported tag types
528
501
pub fn tagtypes ( & mut self ) -> Result < Vec < String > > {
529
502
self . run_command ( "tagtypes" , ( ) )
530
- . and_then ( |_| {
531
- self . read_pairs ( )
532
- . filter ( |r| {
533
- r. as_ref ( )
534
- . map ( |& ( ref a, _) | * a == "tagtype" )
535
- . unwrap_or ( true )
536
- } )
537
- . map ( |r| r. map ( |( _, b) | b) )
538
- . collect ( )
539
- } )
503
+ . and_then ( |_| self . read_list ( "tagtype" ) )
540
504
}
541
505
542
506
/// List all available decoder plugins
@@ -549,16 +513,8 @@ impl<S: Read + Write> Client<S> {
549
513
/// List all channels available for current connection
550
514
pub fn channels ( & mut self ) -> Result < Vec < Channel > > {
551
515
self . run_command ( "channels" , ( ) )
552
- . and_then ( |_| {
553
- self . read_pairs ( )
554
- . filter ( |r| {
555
- r. as_ref ( )
556
- . map ( |& ( ref a, _) | * a == "channel" )
557
- . unwrap_or ( true )
558
- } )
559
- . map ( |r| r. map ( |( _, b) | unsafe { Channel :: new_unchecked ( b) } ) )
560
- . collect ( )
561
- } )
516
+ . and_then ( |_| self . read_list ( "channel" ) )
517
+ . map ( |v| v. into_iter ( ) . map ( |b| unsafe { Channel :: new_unchecked ( b) } ) . collect ( ) )
562
518
}
563
519
564
520
/// Read queued messages from subscribed channels
@@ -681,16 +637,7 @@ impl<S: Read + Write> Client<S> {
681
637
/// with a tag set to given value
682
638
pub fn find_sticker_eq ( & mut self , typ : & str , uri : & str , name : & str , value : & str ) -> Result < Vec < String > > {
683
639
self . run_command ( "sticker find" , ( typ, uri, name, value) )
684
- . and_then ( |_| {
685
- self . read_pairs ( )
686
- . filter ( |r| {
687
- r. as_ref ( )
688
- . map ( |& ( ref a, _) | * a == "file" )
689
- . unwrap_or ( true )
690
- } )
691
- . map ( |r| r. map ( |( _, b) | b) )
692
- . collect ( )
693
- } )
640
+ . and_then ( |_| self . read_list ( "file" ) )
694
641
}
695
642
// }}}
696
643
}
0 commit comments