Skip to main content

NetworkProvider

Trait NetworkProvider 

Source
pub trait NetworkProvider:
    Clone
    + Send
    + Sync
    + 'static {
    type TcpStream: AsyncRead + AsyncWrite + Unpin + Send + 'static;
    type TcpListener: TcpListenerTrait<TcpStream = Self::TcpStream> + 'static;

    // Required methods
    fn bind(
        &self,
        addr: &str,
    ) -> impl Future<Output = Result<Self::TcpListener, Error>> + Send;
    fn connect(
        &self,
        addr: &str,
    ) -> impl Future<Output = Result<Self::TcpStream, Error>> + Send;
}
Expand description

Provider trait for creating network connections and listeners.

Clone allows sharing providers across multiple peers efficiently.

Required Associated Types§

Source

type TcpStream: AsyncRead + AsyncWrite + Unpin + Send + 'static

The TCP stream type for this provider.

Source

type TcpListener: TcpListenerTrait<TcpStream = Self::TcpStream> + 'static

The TCP listener type for this provider.

Required Methods§

Source

fn bind( &self, addr: &str, ) -> impl Future<Output = Result<Self::TcpListener, Error>> + Send

Create a TCP listener bound to the given address.

Source

fn connect( &self, addr: &str, ) -> impl Future<Output = Result<Self::TcpStream, Error>> + Send

Connect to a remote address.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§