use async_rustls::server::TlsStream;
use async_std::net::TcpStream;
#[tide::utils::async_trait]
pub trait CustomTlsAcceptor: Send + Sync {
async fn accept(&self, stream: TcpStream) -> std::io::Result<Option<TlsStream<TcpStream>>>;
}
pub(crate) struct StandardTlsAcceptor(pub(crate) async_rustls::TlsAcceptor);
#[tide::utils::async_trait]
impl CustomTlsAcceptor for StandardTlsAcceptor {
async fn accept(&self, stream: TcpStream) -> std::io::Result<Option<TlsStream<TcpStream>>> {
self.0.accept(stream).await.map(Some)
}
}