diff --git a/Cargo.toml b/Cargo.toml index 75584b3..b600b33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,8 +16,8 @@ name = "imap" path = "src/lib.rs" [dependencies] -openssl = "0.7.13" -regex = "0.1.71" +openssl = "0.8" +regex = "0.1" [dev-dependencies] -base64 = "0.2.0" +base64 = "0.2" diff --git a/src/client.rs b/src/client.rs index d56ed22..b51784b 100644 --- a/src/client.rs +++ b/src/client.rs @@ -314,6 +314,7 @@ mod tests { use super::*; use super::super::mock_stream::MockStream; use super::super::mailbox::Mailbox; + use super::super::error::Result; #[test] fn read_response() { @@ -549,8 +550,8 @@ mod tests { generic_store(" UID ", |mut c, set, query| c.uid_store(set, query)); } - fn generic_store(prefix: &str, op: F) - where F: FnOnce(&mut Client, &str, &str) -> Result { + fn generic_store(prefix: &str, op: F) + where F: FnOnce(&mut Client, &str, &str) -> Result { let res = "* 2 FETCH (FLAGS (\\Deleted \\Seen))\r\n\ * 3 FETCH (FLAGS (\\Deleted))\r\n\ @@ -577,8 +578,8 @@ mod tests { generic_copy(" UID ", |mut c, set, query| c.uid_copy(set, query)) } - fn generic_copy(prefix: &str, op: F) - where F: FnOnce(&mut Client, &str, &str) -> Result { + fn generic_copy(prefix: &str, op: F) + where F: FnOnce(&mut Client, &str, &str) -> Result { generic_with_uid( "OK COPY completed\r\n", @@ -600,8 +601,8 @@ mod tests { generic_fetch(" UID ", |mut c, seq, query| c.uid_fetch(seq, query)) } - fn generic_fetch(prefix: &str, op: F) - where F: FnOnce(&mut Client, &str, &str) -> Result { + fn generic_fetch(prefix: &str, op: F) + where F: FnOnce(&mut Client, &str, &str) -> Result { generic_with_uid( "OK FETCH completed\r\n", @@ -613,13 +614,13 @@ mod tests { ); } - fn generic_with_uid( + fn generic_with_uid( res: &str, cmd: &str, seq: &str, query: &str, prefix: &str, - op: F) where F: FnOnce(&mut Client, &str, &str) -> Result, + op: F) where F: FnOnce(&mut Client, &str, &str) -> Result, { let resp = format!("a1 {}\r\n", res).as_bytes().to_vec(); diff --git a/src/error.rs b/src/error.rs index d9e8e84..28ee761 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,8 +2,9 @@ use std::io::Error as IoError; use std::result; use std::fmt; use std::error::Error as StdError; +use std::net::TcpStream; -use openssl::ssl::error::SslError; +use openssl::ssl::HandshakeError as SslError; pub type Result = result::Result; @@ -13,7 +14,7 @@ pub enum Error { /// An `io::Error` that occurred while trying to read or write to a network stream. Io(IoError), /// An error from the `openssl` library. - Ssl(SslError), + Ssl(SslError), /// A BAD response from the IMAP server. BadResponse(Vec), /// A NO response from the IMAP server. @@ -28,8 +29,8 @@ impl From for Error { } } -impl From for Error { - fn from(err: SslError) -> Error { +impl From> for Error { + fn from(err: SslError) -> Error { Error::Ssl(err) } } diff --git a/src/mock_stream.rs b/src/mock_stream.rs index 94c28e2..20f96a8 100644 --- a/src/mock_stream.rs +++ b/src/mock_stream.rs @@ -1,4 +1,5 @@ use std::io::{Read, Result, Write, Error, ErrorKind}; +use std::cmp::min; pub struct MockStream { read_buf: Vec, @@ -55,13 +56,3 @@ impl Write for MockStream { Ok(()) } } - -fn min(a: usize, b: usize) -> usize { - if a < b { - a - } else if b < a { - b - } else { - a - } -}