@@ -305,6 +305,15 @@ named!(capability_data<Response>, do_parse!(
305
305
( Response :: Capabilities ( capabilities) )
306
306
) ) ;
307
307
308
+ named ! ( mailbox_data_search<Response >, do_parse!(
309
+ tag_s!( "SEARCH" ) >>
310
+ ids: many0!( do_parse!(
311
+ tag_s!( " " ) >>
312
+ id: number >>
313
+ ( id) ) ) >>
314
+ ( Response :: IDs ( ids) )
315
+ ) ) ;
316
+
308
317
named ! ( mailbox_data_flags<Response >, do_parse!(
309
318
tag_s!( "FLAGS " ) >>
310
319
flags: flag_list >>
@@ -405,7 +414,8 @@ named!(mailbox_data<Response>, alt!(
405
414
mailbox_data_list |
406
415
mailbox_data_lsub |
407
416
mailbox_data_status |
408
- mailbox_data_recent
417
+ mailbox_data_recent |
418
+ mailbox_data_search
409
419
) ) ;
410
420
411
421
named ! ( nstring<Option <& [ u8 ] >>, map!(
@@ -726,4 +736,21 @@ mod tests {
726
736
rsp @ _ => panic ! ( "unexpected response {:?}" , rsp) ,
727
737
}
728
738
}
739
+
740
+ #[ test]
741
+ fn test_search ( ) {
742
+ match parse_response ( b"* SEARCH\r \n " ) {
743
+ IResult :: Done ( _, Response :: IDs ( ids) ) => {
744
+ assert ! ( ids. is_empty( ) ) ;
745
+ } ,
746
+ rsp @ _ => panic ! ( "unexpected response {:?}" , rsp) ,
747
+ }
748
+ match parse_response ( b"* SEARCH 12345 67890\r \n " ) {
749
+ IResult :: Done ( _, Response :: IDs ( ids) ) => {
750
+ assert_eq ! ( ids[ 0 ] , 12345 ) ;
751
+ assert_eq ! ( ids[ 1 ] , 67890 ) ;
752
+ } ,
753
+ rsp @ _ => panic ! ( "unexpected response {:?}" , rsp) ,
754
+ }
755
+ }
729
756
}
0 commit comments