fedimint_core::net::peers

Trait IP2PConnections

Source
pub trait IP2PConnections<M>:
    Send
    + Sync
    + 'static {
    // Required methods
    fn send<'life0, 'async_trait>(
        &'life0 self,
        recipient: Recipient,
        msg: M,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn try_send(&self, recipient: Recipient, msg: M);
    fn receive<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Option<(PeerId, M)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn receive_from_peer<'life0, 'async_trait>(
        &'life0 self,
        peer: PeerId,
    ) -> Pin<Box<dyn Future<Output = Option<M>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn into_dyn(self) -> DynP2PConnections<M>
       where Self: Sized { ... }
}
Expand description

Connection manager that tries to keep connections open to all peers

Required Methods§

Source

fn send<'life0, 'async_trait>( &'life0 self, recipient: Recipient, msg: M, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send message to recipient; block if channel is full.

Source

fn try_send(&self, recipient: Recipient, msg: M)

Try to send message to recipient; drop message if channel is full.

Source

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

Await the next message; return None if we are shutting down.

Source

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

Await the next message from peer; return None if we are shutting down.

Provided Methods§

Source

fn into_dyn(self) -> DynP2PConnections<M>
where Self: Sized,

Convert the struct to trait object.

Implementors§

Source§

impl<M: Clone + Send + 'static> IP2PConnections<M> for FakePeerConnections<M>