diff --git a/.travis.yml b/.travis.yml index 1acf8cb..c1dbe59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,8 @@ script: fi - cargo test - cargo test --features early-data + - cargo test ---no-default-features --features client + - cargo test ---no-default-features --features server - cd examples/server - cargo check - cd ../../examples/client diff --git a/Cargo.toml b/Cargo.toml index 60af7c7..a5c68ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,13 +18,24 @@ appveyor = { repository = "async-std/async-tls" } [dependencies] futures = "0.3.4" rustls = "0.18.0" -webpki = "0.21.2" -webpki-roots = "0.19.0" +webpki = { version = "0.21.2", optional = true } +webpki-roots = { version = "0.19.0", optional = true } [features] +default = ["client", "server"] +client = ["webpki", "webpki-roots"] early-data = [] +server = [] [dev-dependencies] lazy_static = "1" futures-util = "0.3" async-std = { version = "1.0", features = ["unstable"] } + +[[test]] +name = "test" +required-features = ["client", "server"] + +[[test]] +name = "google" +required-features = ["client"] diff --git a/README.md b/README.md index 6b81178..183f266 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,29 @@
+# Features + +`async-tls` can be used both in server and client programs. To save compilation times, you +can switch off parts of this for faster compile times. + +To only use async-tls on a client, deactivate default features and use the "client" feature. + +```toml +[dependencies.async-tls] +version = "0.8" +default-features = false +features = ["client"] +``` + +To only use async-tls on for the server side, deactivate default features and use the "server" feature. + +```toml +[dependencies.async-tls] +version = "0.8" +default-features = false +features = ["server"] +``` + ### Simple Client ```rust diff --git a/src/lib.rs b/src/lib.rs index d45f668..23f0208 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,16 +2,21 @@ #![deny(unsafe_code)] +#[cfg(feature = "server")] mod acceptor; +#[cfg(feature = "client")] pub mod client; mod common; +#[cfg(feature = "client")] mod connector; mod rusttls; +#[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub use acceptor::{Accept, TlsAcceptor}; +#[cfg(feature = "client")] pub use connector::{Connect, TlsConnector}; -#[cfg(feature = "early-data")] -#[cfg(test)] +#[cfg(all(test, feature = "client", feature = "early-data"))] mod test_0rtt; diff --git a/src/rusttls/stream.rs b/src/rusttls/stream.rs index bbb47ac..b36ac62 100644 --- a/src/rusttls/stream.rs +++ b/src/rusttls/stream.rs @@ -257,6 +257,6 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> AsyncWrite for Stream<' } } -#[cfg(test)] +#[cfg(all(test, feature = "client"))] #[path = "test_stream.rs"] mod test_stream;