tor_rtcompat/
impls.rs

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