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;
type ListenOptions: Clone + Default + 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, 'life2, 'async_trait>(
&'life0 self,
addr: &'life1 ADDR,
options: &'life2 Self::ListenOptions,
) -> Pin<Box<dyn Future<Output = IoResult<Self::Listener>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: '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().
Sourcetype ListenOptions: Clone + Default + Send + Sync + Unpin + 'static
type ListenOptions: Clone + Default + Send + Sync + Unpin + 'static
The options that can be passed to Self::listen().
This includes both options that affect the listening, and options that will apply to any individual accepted connection streams.
It can include options set with setsockopt,
as well as options that influence higher layers (eg, the runtime).
For established streams that are accepted from a listener,
you can use StreamOps to perform additional operations
or to configure additional options.
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.
Sourcefn listen<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
addr: &'life1 ADDR,
options: &'life2 Self::ListenOptions,
) -> Pin<Box<dyn Future<Output = IoResult<Self::Listener>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn listen<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
addr: &'life1 ADDR,
options: &'life2 Self::ListenOptions,
) -> Pin<Box<dyn Future<Output = IoResult<Self::Listener>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Open a listener on a given socket address.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl NetStreamProvider for AsyncStd
Available on crate feature async-std and (crate features async-std or smol or tokio) and (crate features native-tls or rustls) only.
impl NetStreamProvider for AsyncStd
async-std and (crate features async-std or smol or tokio) and (crate features native-tls or rustls) only.type Stream = TcpStream
type Listener = TcpListener
type ListenOptions = TcpListenOptions
fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 SocketAddr,
) -> 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, 'life2, 'async_trait>(
&'life0 self,
addr: &'life1 SocketAddr,
options: &'life2 Self::ListenOptions,
) -> Pin<Box<dyn Future<Output = IoResult<Self::Listener>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§impl NetStreamProvider<SocketAddr> for AsyncStd
Available on crate feature async-std and (crate features async-std or smol or tokio) and (crate features native-tls or rustls) only.
impl NetStreamProvider<SocketAddr> for AsyncStd
async-std and (crate features async-std or smol or tokio) and (crate features native-tls or rustls) only.type Stream = UnixStream
type Listener = UnixListener
type ListenOptions = UnixListenOptions
fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 SocketAddr,
) -> 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, 'life2, 'async_trait>(
&'life0 self,
addr: &'life1 SocketAddr,
options: &'life2 Self::ListenOptions,
) -> Pin<Box<dyn Future<Output = IoResult<Self::Listener>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Implementors§
Source§impl NetStreamProvider for AsyncStdNativeTlsRuntime
Available on crate feature async-std and (crate features native-tls or rustls) only.
impl NetStreamProvider for AsyncStdNativeTlsRuntime
async-std and (crate features native-tls or rustls) only.type Stream = <CompoundRuntime<AsyncStd, AsyncStd, RealCoarseTimeProvider, AsyncStd, AsyncStd, NativeTlsProvider, AsyncStd> as NetStreamProvider>::Stream
type Listener = <CompoundRuntime<AsyncStd, AsyncStd, RealCoarseTimeProvider, AsyncStd, AsyncStd, NativeTlsProvider, AsyncStd> as NetStreamProvider>::Listener
type ListenOptions = <CompoundRuntime<AsyncStd, AsyncStd, RealCoarseTimeProvider, AsyncStd, AsyncStd, NativeTlsProvider, AsyncStd> as NetStreamProvider>::ListenOptions
Source§impl NetStreamProvider for AsyncStdRustlsRuntime
Available on crate feature async-std and (crate features native-tls or rustls) only.
impl NetStreamProvider for AsyncStdRustlsRuntime
async-std and (crate features native-tls or rustls) only.type Stream = <CompoundRuntime<AsyncStd, AsyncStd, RealCoarseTimeProvider, AsyncStd, AsyncStd, RustlsProvider, AsyncStd> as NetStreamProvider>::Stream
type Listener = <CompoundRuntime<AsyncStd, AsyncStd, RealCoarseTimeProvider, AsyncStd, AsyncStd, RustlsProvider, AsyncStd> as NetStreamProvider>::Listener
type ListenOptions = <CompoundRuntime<AsyncStd, AsyncStd, RealCoarseTimeProvider, AsyncStd, AsyncStd, RustlsProvider, AsyncStd> as NetStreamProvider>::ListenOptions
Source§impl NetStreamProvider for PreferredRuntime
impl NetStreamProvider for PreferredRuntime
type Stream = <TokioNativeTlsRuntime as NetStreamProvider>::Stream
type Listener = <TokioNativeTlsRuntime as NetStreamProvider>::Listener
type ListenOptions = <TokioNativeTlsRuntime as NetStreamProvider>::ListenOptions
Source§impl NetStreamProvider for SmolNativeTlsRuntime
Available on crate feature smol and (crate features native-tls or rustls) only.
impl NetStreamProvider for SmolNativeTlsRuntime
smol and (crate features native-tls or rustls) only.type Stream = <CompoundRuntime<SmolRuntime, SmolRuntime, RealCoarseTimeProvider, SmolRuntime, SmolRuntime, NativeTlsProvider, SmolRuntime> as NetStreamProvider>::Stream
type Listener = <CompoundRuntime<SmolRuntime, SmolRuntime, RealCoarseTimeProvider, SmolRuntime, SmolRuntime, NativeTlsProvider, SmolRuntime> as NetStreamProvider>::Listener
type ListenOptions = <CompoundRuntime<SmolRuntime, SmolRuntime, RealCoarseTimeProvider, SmolRuntime, SmolRuntime, NativeTlsProvider, SmolRuntime> as NetStreamProvider>::ListenOptions
Source§impl NetStreamProvider for SmolRustlsRuntime
Available on crate feature smol and (crate features native-tls or rustls) only.
impl NetStreamProvider for SmolRustlsRuntime
smol and (crate features native-tls or rustls) only.type Stream = <CompoundRuntime<SmolRuntime, SmolRuntime, RealCoarseTimeProvider, SmolRuntime, SmolRuntime, RustlsProvider, SmolRuntime> as NetStreamProvider>::Stream
type Listener = <CompoundRuntime<SmolRuntime, SmolRuntime, RealCoarseTimeProvider, SmolRuntime, SmolRuntime, RustlsProvider, SmolRuntime> as NetStreamProvider>::Listener
type ListenOptions = <CompoundRuntime<SmolRuntime, SmolRuntime, RealCoarseTimeProvider, SmolRuntime, SmolRuntime, RustlsProvider, SmolRuntime> as NetStreamProvider>::ListenOptions
Source§impl NetStreamProvider for TokioNativeTlsRuntime
Available on crate feature tokio and (crate features native-tls or rustls) only.
impl NetStreamProvider for TokioNativeTlsRuntime
tokio and (crate features native-tls or rustls) 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
type ListenOptions = <CompoundRuntime<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle> as NetStreamProvider>::ListenOptions
Source§impl NetStreamProvider for TokioRustlsRuntime
Available on crate feature tokio and (crate features native-tls or rustls) only.
impl NetStreamProvider for TokioRustlsRuntime
tokio and (crate features native-tls or rustls) only.type Stream = <CompoundRuntime<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, RustlsProvider, TokioRuntimeHandle> as NetStreamProvider>::Stream
type Listener = <CompoundRuntime<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, RustlsProvider, TokioRuntimeHandle> as NetStreamProvider>::Listener
type ListenOptions = <CompoundRuntime<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, RustlsProvider, TokioRuntimeHandle> as NetStreamProvider>::ListenOptions
Source§impl NetStreamProvider<SocketAddr> for AsyncStdNativeTlsRuntime
Available on crate feature async-std and (crate features native-tls or rustls) only.
impl NetStreamProvider<SocketAddr> for AsyncStdNativeTlsRuntime
async-std and (crate features native-tls or rustls) only.type Stream = <CompoundRuntime<AsyncStd, AsyncStd, RealCoarseTimeProvider, AsyncStd, AsyncStd, NativeTlsProvider, AsyncStd> as NetStreamProvider<SocketAddr>>::Stream
type Listener = <CompoundRuntime<AsyncStd, AsyncStd, RealCoarseTimeProvider, AsyncStd, AsyncStd, NativeTlsProvider, AsyncStd> as NetStreamProvider<SocketAddr>>::Listener
type ListenOptions = <CompoundRuntime<AsyncStd, AsyncStd, RealCoarseTimeProvider, AsyncStd, AsyncStd, NativeTlsProvider, AsyncStd> as NetStreamProvider<SocketAddr>>::ListenOptions
Source§impl NetStreamProvider<SocketAddr> for AsyncStdRustlsRuntime
Available on crate feature async-std and (crate features native-tls or rustls) only.
impl NetStreamProvider<SocketAddr> for AsyncStdRustlsRuntime
async-std and (crate features native-tls or rustls) only.type Stream = <CompoundRuntime<AsyncStd, AsyncStd, RealCoarseTimeProvider, AsyncStd, AsyncStd, RustlsProvider, AsyncStd> as NetStreamProvider<SocketAddr>>::Stream
type Listener = <CompoundRuntime<AsyncStd, AsyncStd, RealCoarseTimeProvider, AsyncStd, AsyncStd, RustlsProvider, AsyncStd> as NetStreamProvider<SocketAddr>>::Listener
type ListenOptions = <CompoundRuntime<AsyncStd, AsyncStd, RealCoarseTimeProvider, AsyncStd, AsyncStd, RustlsProvider, AsyncStd> as NetStreamProvider<SocketAddr>>::ListenOptions
Source§impl NetStreamProvider<SocketAddr> for SmolNativeTlsRuntime
Available on crate feature smol and (crate features native-tls or rustls) only.
impl NetStreamProvider<SocketAddr> for SmolNativeTlsRuntime
smol and (crate features native-tls or rustls) only.type Stream = <CompoundRuntime<SmolRuntime, SmolRuntime, RealCoarseTimeProvider, SmolRuntime, SmolRuntime, NativeTlsProvider, SmolRuntime> as NetStreamProvider<SocketAddr>>::Stream
type Listener = <CompoundRuntime<SmolRuntime, SmolRuntime, RealCoarseTimeProvider, SmolRuntime, SmolRuntime, NativeTlsProvider, SmolRuntime> as NetStreamProvider<SocketAddr>>::Listener
type ListenOptions = <CompoundRuntime<SmolRuntime, SmolRuntime, RealCoarseTimeProvider, SmolRuntime, SmolRuntime, NativeTlsProvider, SmolRuntime> as NetStreamProvider<SocketAddr>>::ListenOptions
Source§impl NetStreamProvider<SocketAddr> for SmolRustlsRuntime
Available on crate feature smol and (crate features native-tls or rustls) only.
impl NetStreamProvider<SocketAddr> for SmolRustlsRuntime
smol and (crate features native-tls or rustls) only.type Stream = <CompoundRuntime<SmolRuntime, SmolRuntime, RealCoarseTimeProvider, SmolRuntime, SmolRuntime, RustlsProvider, SmolRuntime> as NetStreamProvider<SocketAddr>>::Stream
type Listener = <CompoundRuntime<SmolRuntime, SmolRuntime, RealCoarseTimeProvider, SmolRuntime, SmolRuntime, RustlsProvider, SmolRuntime> as NetStreamProvider<SocketAddr>>::Listener
type ListenOptions = <CompoundRuntime<SmolRuntime, SmolRuntime, RealCoarseTimeProvider, SmolRuntime, SmolRuntime, RustlsProvider, SmolRuntime> as NetStreamProvider<SocketAddr>>::ListenOptions
Source§impl NetStreamProvider<SocketAddr> for TokioNativeTlsRuntime
Available on crate feature tokio and (crate features native-tls or rustls) only.
impl NetStreamProvider<SocketAddr> for TokioNativeTlsRuntime
tokio and (crate features native-tls or rustls) only.type Stream = <CompoundRuntime<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle> as NetStreamProvider<SocketAddr>>::Stream
type Listener = <CompoundRuntime<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle> as NetStreamProvider<SocketAddr>>::Listener
type ListenOptions = <CompoundRuntime<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle> as NetStreamProvider<SocketAddr>>::ListenOptions
Source§impl NetStreamProvider<SocketAddr> for TokioRustlsRuntime
Available on crate feature tokio and (crate features native-tls or rustls) only.
impl NetStreamProvider<SocketAddr> for TokioRustlsRuntime
tokio and (crate features native-tls or rustls) only.