From 741a83e1a59a9ed822ce6d1ab1a82d31a1cc854a Mon Sep 17 00:00:00 2001 From: hozan23 Date: Sat, 22 Jun 2024 05:21:42 +0200 Subject: net: compile rustls only if tls feature is enabled --- net/async_rustls/Cargo.toml | 19 +++++++++++++++++++ net/async_rustls/src/lib.rs | 12 ++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 net/async_rustls/Cargo.toml create mode 100644 net/async_rustls/src/lib.rs (limited to 'net/async_rustls') diff --git a/net/async_rustls/Cargo.toml b/net/async_rustls/Cargo.toml new file mode 100644 index 0000000..0d40e8a --- /dev/null +++ b/net/async_rustls/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "karyon_async_rustls" +description = "Internal crate for Karyon library." +version.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true +license.workspace = true +authors.workspace = true + +[features] +default = ["smol"] +smol = ["futures-rustls"] +tokio = ["tokio-rustls"] + +[dependencies] +futures-rustls = { version = "0.25.1", optional = true } +tokio-rustls = { version = "0.26.0", optional = true } + diff --git a/net/async_rustls/src/lib.rs b/net/async_rustls/src/lib.rs new file mode 100644 index 0000000..4365552 --- /dev/null +++ b/net/async_rustls/src/lib.rs @@ -0,0 +1,12 @@ +#[cfg(all(feature = "smol", feature = "tokio"))] +compile_error!("Only one async runtime feature should be enabled"); + +#[cfg(not(any(feature = "smol", feature = "tokio")))] +compile_error!("At least one async runtime feature must be enabled for this crate."); + +#[cfg(feature = "smol")] +pub use futures_rustls::{rustls, TlsAcceptor, TlsConnector, TlsStream}; + +#[cfg(feature = "tokio")] +pub use tokio_rustls::{rustls, TlsAcceptor, TlsConnector, TlsStream}; + -- cgit v1.2.3