diff --git a/src/client.rs b/src/client.rs index 9a198b2..a5448be 100644 --- a/src/client.rs +++ b/src/client.rs @@ -623,15 +623,14 @@ impl Session { /// Searches the mailbox for messages that match the given criteria and returns /// the list of message sequence numbers of those messages. - pub fn search(&mut self, query: &str) -> ZeroCopyResult> { + pub fn search(&mut self, query: &str) -> Result> { self.run_command_and_read_response(&format!("SEARCH {}", query)) .and_then(parse_ids) } /// Searches the mailbox for messages that match the given criteria and returns /// the list of unique identifier numbers of those messages. - pub fn uid_search(&mut self, query: &str) -> ZeroCopyResult> { - eprint!("{}", format!("UID SEARCH {}", query)); + pub fn uid_search(&mut self, query: &str) -> Result> { self.run_command_and_read_response(&format!("UID SEARCH {}", query)) .and_then(parse_ids) } diff --git a/src/parse.rs b/src/parse.rs index b042ce1..f4b20b5 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -222,30 +222,27 @@ pub fn parse_mailbox(mut lines: &[u8]) -> Result { } } -pub fn parse_ids(lines: Vec) -> ZeroCopyResult> { - let f = |mut lines| { - let mut ids = HashSet::new(); - loop { - match imap_proto::parse_response(lines) { - IResult::Done(rest, Response::IDs(c)) => { - lines = rest; - ids.extend(c); +pub fn parse_ids(lines: Vec) -> Result> { + let mut lines = &lines[..]; + let mut ids = HashSet::new(); + loop { + match imap_proto::parse_response(lines) { + IResult::Done(rest, Response::IDs(c)) => { + lines = rest; + ids.extend(c); - if lines.is_empty() { - break Ok(ids); - } - } - IResult::Done(_, resp) => { - break Err(resp.into()); - } - _ => { - break Err(Error::Parse(ParseError::Invalid(lines.to_vec()))); + if lines.is_empty() { + break Ok(ids); } } + IResult::Done(_, resp) => { + break Err(resp.into()); + } + _ => { + break Err(Error::Parse(ParseError::Invalid(lines.to_vec()))); + } } - }; - - unsafe { ZeroCopy::new(lines, f) } + } } #[cfg(test)]