Skip to main content

NetworkTransport

Trait NetworkTransport 

Source
pub trait NetworkTransport:
    Send
    + Sync
    + 'static {
    // Required methods
    fn connect<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peer_id: &'life1 PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn disconnect<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peer_id: &'life1 PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn send<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peer_id: &'life1 PeerId,
        message: Message,
    ) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn broadcast<'life0, 'async_trait>(
        &'life0 self,
        message: Message,
    ) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn connected_peers<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Vec<Peer>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn subscribe(&self) -> Receiver<(PeerId, Message)>;
}
Expand description

Abstract network transport trait.

Required Methods§

Source

fn connect<'life0, 'life1, 'async_trait>( &'life0 self, peer_id: &'life1 PeerId, ) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Connect to a peer.

Source

fn disconnect<'life0, 'life1, 'async_trait>( &'life0 self, peer_id: &'life1 PeerId, ) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Disconnect from a peer.

Source

fn send<'life0, 'life1, 'async_trait>( &'life0 self, peer_id: &'life1 PeerId, message: Message, ) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a message to a specific peer.

Source

fn broadcast<'life0, 'async_trait>( &'life0 self, message: Message, ) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Broadcast a message to all connected peers.

Source

fn connected_peers<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<Peer>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get list of connected peers.

Source

fn subscribe(&self) -> Receiver<(PeerId, Message)>

Subscribe to incoming messages.

Implementors§