remove futures 0.2 code

This commit is contained in:
quininer 2018-08-16 17:59:59 +08:00
parent 32d3f46a9e
commit 32f328fc14
4 changed files with 5 additions and 51 deletions

View File

@ -15,20 +15,12 @@ travis-ci = { repository = "quininer/tokio-rustls" }
appveyor = { repository = "quininer/tokio-rustls" } appveyor = { repository = "quininer/tokio-rustls" }
[dependencies] [dependencies]
futures-core = { version = "0.2.0", optional = true }
futures-io = { version = "0.2.0", optional = true }
tokio = { version = "0.1.6", optional = true } tokio = { version = "0.1.6", optional = true }
rustls = "0.13" rustls = "0.13"
webpki = "0.18.1" webpki = "0.18.1"
[dev-dependencies] [dev-dependencies]
# futures = "0.2.0"
tokio = "0.1.6" tokio = "0.1.6"
[features] [features]
default = [ "tokio" ] default = [ "tokio" ]
# unstable-futures = [
# "futures-core",
# "futures-io",
# "tokio/unstable-futures"
# ]

View File

@ -3,8 +3,9 @@
pub extern crate rustls; pub extern crate rustls;
pub extern crate webpki; pub extern crate webpki;
extern crate tokio;
#[cfg(feature = "tokio")] mod tokio_impl; #[cfg(feature = "tokio")] mod tokio_impl;
#[cfg(feature = "unstable-futures")] mod futures_impl;
use std::io; use std::io;
use std::sync::Arc; use std::sync::Arc;

View File

@ -1,9 +1,7 @@
extern crate tokio;
use super::*; use super::*;
use self::tokio::prelude::*; use tokio::prelude::*;
use self::tokio::io::{ AsyncRead, AsyncWrite }; use tokio::io::{ AsyncRead, AsyncWrite };
use self::tokio::prelude::Poll; use tokio::prelude::Poll;
impl<S: AsyncRead + AsyncWrite> Future for ConnectAsync<S> { impl<S: AsyncRead + AsyncWrite> Future for ConnectAsync<S> {

View File

@ -83,32 +83,6 @@ fn start_client(addr: &SocketAddr, domain: &str, chain: Option<BufReader<Cursor<
done.wait() done.wait()
} }
#[cfg(feature = "unstable-futures")]
fn start_client2(addr: &SocketAddr, domain: &str, chain: Option<BufReader<Cursor<&str>>>) -> 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] #[test]
fn pass() { fn pass() {
@ -120,17 +94,6 @@ fn pass() {
start_client(&addr, "localhost", Some(chain)).unwrap(); 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] #[should_panic]
#[test] #[test]
fn fail() { fn fail() {