From 32f328fc142e6e6379f1ae6445fc58e1cc883ec7 Mon Sep 17 00:00:00 2001 From: quininer Date: Thu, 16 Aug 2018 17:59:59 +0800 Subject: [PATCH] remove futures 0.2 code --- Cargo.toml | 8 -------- src/lib.rs | 3 ++- src/tokio_impl.rs | 8 +++----- tests/test.rs | 37 ------------------------------------- 4 files changed, 5 insertions(+), 51 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e289e0f..5d06420 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,20 +15,12 @@ travis-ci = { repository = "quininer/tokio-rustls" } appveyor = { repository = "quininer/tokio-rustls" } [dependencies] -futures-core = { version = "0.2.0", optional = true } -futures-io = { version = "0.2.0", optional = true } tokio = { version = "0.1.6", optional = true } rustls = "0.13" webpki = "0.18.1" [dev-dependencies] -# futures = "0.2.0" tokio = "0.1.6" [features] default = [ "tokio" ] -# unstable-futures = [ -# "futures-core", -# "futures-io", -# "tokio/unstable-futures" -# ] diff --git a/src/lib.rs b/src/lib.rs index d1c6c7d..69db77d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,8 +3,9 @@ pub extern crate rustls; pub extern crate webpki; +extern crate tokio; + #[cfg(feature = "tokio")] mod tokio_impl; -#[cfg(feature = "unstable-futures")] mod futures_impl; use std::io; use std::sync::Arc; diff --git a/src/tokio_impl.rs b/src/tokio_impl.rs index 936c14b..e9a00a9 100644 --- a/src/tokio_impl.rs +++ b/src/tokio_impl.rs @@ -1,9 +1,7 @@ -extern crate tokio; - use super::*; -use self::tokio::prelude::*; -use self::tokio::io::{ AsyncRead, AsyncWrite }; -use self::tokio::prelude::Poll; +use tokio::prelude::*; +use tokio::io::{ AsyncRead, AsyncWrite }; +use tokio::prelude::Poll; impl Future for ConnectAsync { diff --git a/tests/test.rs b/tests/test.rs index e64dd82..c6262e9 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -83,32 +83,6 @@ fn start_client(addr: &SocketAddr, domain: &str, chain: Option>>) -> io::Result<()> { - use futures::FutureExt; - use futures::io::{ AsyncReadExt, AsyncWriteExt }; - use futures::executor::block_on; - - let domain = webpki::DNSNameRef::try_from_ascii_str(domain).unwrap(); - let mut config = ClientConfig::new(); - if let Some(mut chain) = chain { - config.root_store.add_pem_file(&mut chain).unwrap(); - } - let config = Arc::new(config); - - let done = TcpStream::connect(addr) - .and_then(|stream| config.connect_async(domain, stream)) - .and_then(|stream| stream.write_all(HELLO_WORLD)) - .and_then(|(stream, _)| stream.read_exact(vec![0; HELLO_WORLD.len()])) - .and_then(|(stream, buf)| { - assert_eq!(buf, HELLO_WORLD); - stream.close() - }) - .map(drop); - - block_on(done) -} - #[test] fn pass() { @@ -120,17 +94,6 @@ fn pass() { start_client(&addr, "localhost", Some(chain)).unwrap(); } -#[cfg(feature = "unstable-futures")] -#[test] -fn pass2() { - let cert = certs(&mut BufReader::new(Cursor::new(CERT))).unwrap(); - let mut keys = rsa_private_keys(&mut BufReader::new(Cursor::new(RSA))).unwrap(); - let chain = BufReader::new(Cursor::new(CHAIN)); - - let addr = start_server(cert, keys.pop().unwrap()); - start_client2(&addr, "localhost", Some(chain)).unwrap(); -} - #[should_panic] #[test] fn fail() {