Skip to content

Commit 09848b9

Browse files
committed
Merge changes from old repository
2 parents b42f850 + 4ecd2f5 commit 09848b9

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

imap-proto/src/parser.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,15 @@ named!(capability_data<Response>, do_parse!(
305305
(Response::Capabilities(capabilities))
306306
));
307307

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+
308317
named!(mailbox_data_flags<Response>, do_parse!(
309318
tag_s!("FLAGS ") >>
310319
flags: flag_list >>
@@ -405,7 +414,8 @@ named!(mailbox_data<Response>, alt!(
405414
mailbox_data_list |
406415
mailbox_data_lsub |
407416
mailbox_data_status |
408-
mailbox_data_recent
417+
mailbox_data_recent |
418+
mailbox_data_search
409419
));
410420

411421
named!(nstring<Option<&[u8]>>, map!(
@@ -726,4 +736,21 @@ mod tests {
726736
rsp @ _ => panic!("unexpected response {:?}", rsp),
727737
}
728738
}
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+
}
729756
}

imap-proto/src/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub enum Response<'a> {
3131
Expunge(u32),
3232
Fetch(u32, Vec<AttributeValue<'a>>),
3333
MailboxData(MailboxDatum<'a>),
34+
IDs(Vec<u32>),
3435
}
3536

3637
#[derive(Debug, Eq, PartialEq)]

0 commit comments

Comments
 (0)