tor_rtcompat/
impls.rs

1//! Different implementations of a common async API for use in arti
2//!
3//! Currently only async_std, tokio and smol are provided.
4
5#[cfg(feature = "async-std")]
6pub(crate) mod async_std;
7
8#[cfg(feature = "tokio")]
9pub(crate) mod tokio;
10
11#[cfg(feature = "smol")]
12pub(crate) mod smol;
13
14#[cfg(feature = "rustls")]
15pub(crate) mod rustls;
16
17#[cfg(feature = "native-tls")]
18pub(crate) mod native_tls;
19
20pub(crate) mod streamops;
21
22/// Helper: Implement an unreachable NetProvider<unix::SocketAddr> for a given runtime.
23#[cfg(not(unix))]
24macro_rules! impl_unix_non_provider {
25    { $for_type:ty } => {
26
27        #[async_trait]
28        impl crate::traits::NetStreamProvider<tor_general_addr::unix::SocketAddr> for $for_type {
29            type Stream = crate::unimpl::FakeStream;
30            type Listener = crate::unimpl::FakeListener<tor_general_addr::unix::SocketAddr>;
31            async fn connect(&self, _a: &tor_general_addr::unix::SocketAddr) -> IoResult<Self::Stream> {
32                Err(tor_general_addr::unix::NoAfUnixSocketSupport::default().into())
33
34            }
35            async fn listen(&self, _a: &tor_general_addr::unix::SocketAddr) -> IoResult<Self::Listener> {
36                Err(tor_general_addr::unix::NoAfUnixSocketSupport::default().into())
37            }
38        }
39    }
40}
41#[cfg(not(unix))]
42pub(crate) use impl_unix_non_provider;