Closed qsdgy closed 1 year ago
I'd be happy to review a PR!
nom seems cool, I will try it if have the chance.
All Okay, @qsdgy
let mut values = HashMap::new();
values.insert("name".into(), "Cyrus".into());
values.insert("version".into(), "1.5".into());
values.insert("os".into(), "sunos".into());
values.insert("os-version".into(), "5.5".into());
values.insert("support-url".into(), "mailto:cyrus-bugs+@andrew.cmu.edu".into());
match imap_proto::parser::parse_response(b"* ID (\"name\" \"Cyrus\" \"version\" \"1.5\" \"os\" \"sunos\" \"os-version\" \"5.5\" \"support-url\" \"mailto:cyrus-bugs+@andrew.cmu.edu\")\r\n") {
Ok((_, Response::Id(Some(mapped)))) if mapped.eq(&values) => {}
rsp => panic!("unexpected response {rsp:?}"),
}
let line = b"* ID (\"name\" \"Cyrus\" \"version\" \"1.5\" \"os\" \"sunos\" \"os-version\" \"5.5\" \"support-url\" \"mailto:cyrus-bugs+@andrew.cmu.edu\")\r\n";
match Response::from_bytes(line) {
Ok((remaining, command)) => {
println!("{:#?}", command);
if !remaining.is_empty() {
println!("Remaining data in buffer: {:?}", remaining);
}
}
Err(e) => {
println!("Error parsing the response. Is it correct? Exiting.");
println!("{:?}", e);
}
}
IMAP4 ID extension
example from here
Some mail service provider enforce clients provide ID info, it's useful to deal with that (e.g. jonhoo/rust-imap#211 ).