Trait melnet2::Backhaul

source ·
pub trait Backhaul: Send + Sync + Clone + 'static {
    type RpcTransport: RpcTransport;
    type ConnectError: Error + Send + Sync;
    type ListenError;

    // Required methods
    fn connect<'life0, 'async_trait>(
        &'life0 self,
        remote_addr: Address
    ) -> Pin<Box<dyn Future<Output = Result<Self::RpcTransport, Self::ConnectError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn start_listen<'life0, 'async_trait>(
        &'life0 self,
        local_addr: Address,
        handler: impl 'async_trait + RpcService
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::ListenError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn connect_lazy<'life0, 'async_trait>(
        &'life0 self,
        remote_addr: Address
    ) -> Pin<Box<dyn Future<Output = AutoconnectTransport<Self::RpcTransport, Self::ConnectError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

An implementation of an underlying transport (e.g. TCP) should implement this trait.

Required Associated Types§

Required Methods§

source

fn connect<'life0, 'async_trait>( &'life0 self, remote_addr: Address ) -> Pin<Box<dyn Future<Output = Result<Self::RpcTransport, Self::ConnectError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Connect to a remote address.

source

fn start_listen<'life0, 'async_trait>( &'life0 self, local_addr: Address, handler: impl 'async_trait + RpcService ) -> Pin<Box<dyn Future<Output = Result<(), Self::ListenError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Listen for incoming requests at the given address, directing them to to this responder. Fill in None as the address to listen at all available addresses. Stopping listening is currently not yet supported.

Provided Methods§

source

fn connect_lazy<'life0, 'async_trait>( &'life0 self, remote_addr: Address ) -> Pin<Box<dyn Future<Output = AutoconnectTransport<Self::RpcTransport, Self::ConnectError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Return an RpcTransport that tries to connect to the remote address only when used.

Implementors§