update to openssl 0.8 and unspecify micro versions (#22)

This commit is contained in:
drevilt 2017-03-02 23:08:54 +01:00 committed by Matt McCoy
parent 0eaf3709e6
commit dc3b4f92e6
4 changed files with 18 additions and 25 deletions

View file

@ -16,8 +16,8 @@ name = "imap"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
openssl = "0.7.13" openssl = "0.8"
regex = "0.1.71" regex = "0.1"
[dev-dependencies] [dev-dependencies]
base64 = "0.2.0" base64 = "0.2"

View file

@ -314,6 +314,7 @@ mod tests {
use super::*; use super::*;
use super::super::mock_stream::MockStream; use super::super::mock_stream::MockStream;
use super::super::mailbox::Mailbox; use super::super::mailbox::Mailbox;
use super::super::error::Result;
#[test] #[test]
fn read_response() { fn read_response() {
@ -549,8 +550,8 @@ mod tests {
generic_store(" UID ", |mut c, set, query| c.uid_store(set, query)); generic_store(" UID ", |mut c, set, query| c.uid_store(set, query));
} }
fn generic_store<F, T, E>(prefix: &str, op: F) fn generic_store<F, T>(prefix: &str, op: F)
where F: FnOnce(&mut Client<MockStream>, &str, &str) -> Result<T, E> { where F: FnOnce(&mut Client<MockStream>, &str, &str) -> Result<T> {
let res = "* 2 FETCH (FLAGS (\\Deleted \\Seen))\r\n\ let res = "* 2 FETCH (FLAGS (\\Deleted \\Seen))\r\n\
* 3 FETCH (FLAGS (\\Deleted))\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)) generic_copy(" UID ", |mut c, set, query| c.uid_copy(set, query))
} }
fn generic_copy<F, T, E>(prefix: &str, op: F) fn generic_copy<F, T>(prefix: &str, op: F)
where F: FnOnce(&mut Client<MockStream>, &str, &str) -> Result<T, E> { where F: FnOnce(&mut Client<MockStream>, &str, &str) -> Result<T> {
generic_with_uid( generic_with_uid(
"OK COPY completed\r\n", "OK COPY completed\r\n",
@ -600,8 +601,8 @@ mod tests {
generic_fetch(" UID ", |mut c, seq, query| c.uid_fetch(seq, query)) generic_fetch(" UID ", |mut c, seq, query| c.uid_fetch(seq, query))
} }
fn generic_fetch<F, T, E>(prefix: &str, op: F) fn generic_fetch<F, T>(prefix: &str, op: F)
where F: FnOnce(&mut Client<MockStream>, &str, &str) -> Result<T, E> { where F: FnOnce(&mut Client<MockStream>, &str, &str) -> Result<T> {
generic_with_uid( generic_with_uid(
"OK FETCH completed\r\n", "OK FETCH completed\r\n",
@ -613,13 +614,13 @@ mod tests {
); );
} }
fn generic_with_uid<F, T, E>( fn generic_with_uid<F, T>(
res: &str, res: &str,
cmd: &str, cmd: &str,
seq: &str, seq: &str,
query: &str, query: &str,
prefix: &str, prefix: &str,
op: F) where F: FnOnce(&mut Client<MockStream>, &str, &str) -> Result<T, E>, op: F) where F: FnOnce(&mut Client<MockStream>, &str, &str) -> Result<T>,
{ {
let resp = format!("a1 {}\r\n", res).as_bytes().to_vec(); let resp = format!("a1 {}\r\n", res).as_bytes().to_vec();

View file

@ -2,8 +2,9 @@ use std::io::Error as IoError;
use std::result; use std::result;
use std::fmt; use std::fmt;
use std::error::Error as StdError; use std::error::Error as StdError;
use std::net::TcpStream;
use openssl::ssl::error::SslError; use openssl::ssl::HandshakeError as SslError;
pub type Result<T> = result::Result<T, Error>; pub type Result<T> = result::Result<T, Error>;
@ -13,7 +14,7 @@ pub enum Error {
/// An `io::Error` that occurred while trying to read or write to a network stream. /// An `io::Error` that occurred while trying to read or write to a network stream.
Io(IoError), Io(IoError),
/// An error from the `openssl` library. /// An error from the `openssl` library.
Ssl(SslError), Ssl(SslError<TcpStream>),
/// A BAD response from the IMAP server. /// A BAD response from the IMAP server.
BadResponse(Vec<String>), BadResponse(Vec<String>),
/// A NO response from the IMAP server. /// A NO response from the IMAP server.
@ -28,8 +29,8 @@ impl From<IoError> for Error {
} }
} }
impl From<SslError> for Error { impl From<SslError<TcpStream>> for Error {
fn from(err: SslError) -> Error { fn from(err: SslError<TcpStream>) -> Error {
Error::Ssl(err) Error::Ssl(err)
} }
} }

View file

@ -1,4 +1,5 @@
use std::io::{Read, Result, Write, Error, ErrorKind}; use std::io::{Read, Result, Write, Error, ErrorKind};
use std::cmp::min;
pub struct MockStream { pub struct MockStream {
read_buf: Vec<u8>, read_buf: Vec<u8>,
@ -55,13 +56,3 @@ impl Write for MockStream {
Ok(()) Ok(())
} }
} }
fn min(a: usize, b: usize) -> usize {
if a < b {
a
} else if b < a {
b
} else {
a
}
}