pub trait NetStreamProvider<ADDR = SocketAddr>:
Clone
+ Send
+ Sync
+ 'static {
type Stream: AsyncRead + AsyncWrite + StreamOps + Send + Sync + Unpin + 'static;
type Listener: NetStreamListener<ADDR, Stream = Self::Stream> + Send + Sync + Unpin + 'static;
// Required methods
fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 ADDR,
) -> Pin<Box<dyn Future<Output = IoResult<Self::Stream>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn listen<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 ADDR,
) -> Pin<Box<dyn Future<Output = IoResult<Self::Listener>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
Trait for a runtime that can create and accept connections over network sockets.
(In Arti we use the AsyncRead
and AsyncWrite
traits from
futures::io
as more standard, even though the ones from Tokio
can be a bit more efficient. Let’s hope that they converge in the
future.)
Required Associated Types§
Sourcetype Stream: AsyncRead + AsyncWrite + StreamOps + Send + Sync + Unpin + 'static
type Stream: AsyncRead + AsyncWrite + StreamOps + Send + Sync + Unpin + 'static
The type for the connections returned by Self::connect()
.
Sourcetype Listener: NetStreamListener<ADDR, Stream = Self::Stream> + Send + Sync + Unpin + 'static
type Listener: NetStreamListener<ADDR, Stream = Self::Stream> + Send + Sync + Unpin + 'static
The type for the listeners returned by Self::listen()
.
Required Methods§
Sourcefn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 ADDR,
) -> Pin<Box<dyn Future<Output = IoResult<Self::Stream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 ADDR,
) -> Pin<Box<dyn Future<Output = IoResult<Self::Stream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Launch a connection connection to a given socket address.
Note that unlike std::net:TcpStream::connect
, we do not accept
any types other than a single ADDR
. We do this because
we must be absolutely sure not to perform
unnecessary DNS lookups.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl NetStreamProvider for PreferredRuntime
impl NetStreamProvider for PreferredRuntime
type Stream = <TokioNativeTlsRuntime as NetStreamProvider>::Stream
type Listener = <TokioNativeTlsRuntime as NetStreamProvider>::Listener
Source§impl NetStreamProvider for TokioNativeTlsRuntime
Available on (crate features native-tls
or rustls
) and crate feature tokio
only.
impl NetStreamProvider for TokioNativeTlsRuntime
native-tls
or rustls
) and crate feature tokio
only.type Stream = <CompoundRuntime<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle> as NetStreamProvider>::Stream
type Listener = <CompoundRuntime<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle> as NetStreamProvider>::Listener
Source§impl NetStreamProvider<SocketAddr> for PreferredRuntime
impl NetStreamProvider<SocketAddr> for PreferredRuntime
type Stream = <TokioNativeTlsRuntime as NetStreamProvider<SocketAddr>>::Stream
type Listener = <TokioNativeTlsRuntime as NetStreamProvider<SocketAddr>>::Listener
Source§impl NetStreamProvider<SocketAddr> for TokioNativeTlsRuntime
Available on (crate features native-tls
or rustls
) and crate feature tokio
only.
impl NetStreamProvider<SocketAddr> for TokioNativeTlsRuntime
native-tls
or rustls
) and crate feature tokio
only.