NetworkProvider

Trait NetworkProvider 

Source
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§

Source

type TcpStream: AsyncRead + AsyncWrite + Unpin + '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<'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,

Create a TCP listener bound to the given address.

Source

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,

Connect to a remote address.

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§