diff --git a/Cargo.toml b/Cargo.toml index ad128b6..374bf4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ thiserror = "1.0.9" futures-util = { version = "0.3.1", features = ["io"], optional = true } tokio = { version = "1.0", default-features = false, features = ["io-util"], optional = true } url = "2.1.1" +async-tls-acceptor = { version = "0.1.0", optional = true } [features] default = ["runtime-async-std"] @@ -27,7 +28,7 @@ default = ["runtime-async-std"] vendored = ["native-tls/vendored"] # Runtime -runtime-async-std = ["futures-util"] +runtime-async-std = ["futures-util", "async-tls-acceptor"] runtime-tokio = ["tokio"] [dev-dependencies] diff --git a/src/acceptor.rs b/src/acceptor.rs index 4535c8a..e97ccfb 100644 --- a/src/acceptor.rs +++ b/src/acceptor.rs @@ -96,6 +96,20 @@ impl From for TlsAcceptor { } } +#[cfg(feature = "runtime-async-std")] +#[async_tls_acceptor::async_trait] +impl async_tls_acceptor::Acceptor for TlsAcceptor +where + Input: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static, +{ + type Output = TlsStream; + type Error = crate::Error; + + async fn accept(&self, input: Input) -> Result { + TlsAcceptor::accept(&self, input).await + } +} + #[cfg(all(test, feature = "runtime-async-std"))] mod tests { use super::*;