Trait fedimint_core::net::peers::IMuxPeerConnections

source ·
pub trait IMuxPeerConnections<MuxKey, Msg>{
    // Required methods
    fn send<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peers: &'life1 [PeerId],
        mux_key: MuxKey,
        msg: Msg,
    ) -> Pin<Box<dyn Future<Output = Cancellable<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn receive<'life0, 'async_trait>(
        &'life0 self,
        mux_key: MuxKey,
    ) -> Pin<Box<dyn Future<Output = Cancellable<(PeerId, Msg)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn ban_peer<'life0, 'async_trait>(
        &'life0 self,
        peer: PeerId,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn into_dyn(self) -> MuxPeerConnections<MuxKey, Msg>
       where Self: Sized + Send + Sync + Unpin + 'static { ... }
}
Expand description

Like IPeerConnections but with an ability to handle multiple destinations (like modules) per each peer-connection.

Notably, unlike IPeerConnections implementations need to be thread-safe, as the primary intended use should support multiple threads using multiplexed channel at the same time.

Required Methods§

source

fn send<'life0, 'life1, 'async_trait>( &'life0 self, peers: &'life1 [PeerId], mux_key: MuxKey, msg: Msg, ) -> Pin<Box<dyn Future<Output = Cancellable<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a message to a specific destination at specific peer.

source

fn receive<'life0, 'async_trait>( &'life0 self, mux_key: MuxKey, ) -> Pin<Box<dyn Future<Output = Cancellable<(PeerId, Msg)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Await receipt of a message from any connected peer.

source

fn ban_peer<'life0, 'async_trait>( &'life0 self, peer: PeerId, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes a peer connection in case of misbehavior

Provided Methods§

source

fn into_dyn(self) -> MuxPeerConnections<MuxKey, Msg>
where Self: Sized + Send + Sync + Unpin + 'static,

Converts the struct to a PeerConnection trait object

Implementors§