pub trait NetworkProvider: Clone {
type TcpStream: AsyncRead + AsyncWrite + Unpin + 'static;
type TcpListener: TcpListenerTrait<TcpStream = Self::TcpStream> + 'static;
// Required methods
fn bind<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Self::TcpListener>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Self::TcpStream>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Provider trait for creating network connections and listeners.
Single-core design - no Send bounds needed. Clone allows sharing providers across multiple peers efficiently.
Required Associated Types§
Sourcetype TcpStream: AsyncRead + AsyncWrite + Unpin + 'static
type TcpStream: AsyncRead + AsyncWrite + Unpin + 'static
The TCP stream type for this provider.
Sourcetype TcpListener: TcpListenerTrait<TcpStream = Self::TcpStream> + 'static
type TcpListener: TcpListenerTrait<TcpStream = Self::TcpStream> + 'static
The TCP listener type for this provider.
Required Methods§
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.