From 6f1787e9d1adf96828630bca320de236b6c6801a Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Fri, 11 Jan 2019 14:03:37 -0800 Subject: [PATCH] Shrink down the dependency on tokio it turns out that tokio-rustls only requires a small portion of the tokio stack. This patch slims down the dependencies since not all clients need the full tokio stack. --- Cargo.toml | 5 +++-- src/common/mod.rs | 4 ++-- src/lib.rs | 4 +++- src/tokio_impl.rs | 5 ++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b4cd9e1..a0e2017 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,8 @@ travis-ci = { repository = "quininer/tokio-rustls" } appveyor = { repository = "quininer/tokio-rustls" } [dependencies] -tokio = { version = "0.1.6", optional = true } +futures = { version = "0.1", optional = true } +tokio-io = { version = "0.1.6", optional = true } bytes = { version = "0.4", optional = true } iovec = { version = "0.1", optional = true } rustls = "0.14" @@ -28,4 +29,4 @@ lazy_static = "1" [features] default = ["tokio-support"] nightly = ["bytes", "iovec"] -tokio-support = ["tokio"] +tokio-support = ["futures", "tokio-io"] diff --git a/src/common/mod.rs b/src/common/mod.rs index e18aa6e..8e4a5b1 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -10,7 +10,7 @@ use rustls::Session; use rustls::WriteV; #[cfg(feature = "nightly")] #[cfg(feature = "tokio-support")] -use tokio::io::AsyncWrite; +use tokio_io::AsyncWrite; pub struct Stream<'a, S: 'a, IO: 'a> { @@ -91,7 +91,7 @@ impl<'a, S: Session, IO: Read + Write> WriteTls<'a, S, IO> for Stream<'a, S, IO> #[cfg(feature = "tokio-support")] impl<'a, S: Session, IO: Read + AsyncWrite> WriteTls<'a, S, IO> for Stream<'a, S, IO> { fn write_tls(&mut self) -> io::Result { - use tokio::prelude::Async; + use futures::Async; use self::vecbuf::VecBuf; struct V<'a, IO: 'a>(&'a mut IO); diff --git a/src/lib.rs b/src/lib.rs index ee1524d..2aaf2e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,9 @@ pub extern crate rustls; pub extern crate webpki; #[cfg(feature = "tokio-support")] -extern crate tokio; +extern crate futures; +#[cfg(feature = "tokio-support")] +extern crate tokio_io; #[cfg(feature = "nightly")] #[cfg(feature = "tokio-support")] extern crate bytes; diff --git a/src/tokio_impl.rs b/src/tokio_impl.rs index 644e4f0..7d9ba57 100644 --- a/src/tokio_impl.rs +++ b/src/tokio_impl.rs @@ -1,7 +1,6 @@ use super::*; -use tokio::prelude::*; -use tokio::io::{ AsyncRead, AsyncWrite }; -use tokio::prelude::Poll; +use tokio_io::{ AsyncRead, AsyncWrite }; +use futures::{Async, Future, Poll}; use common::Stream;