Trait network_clique::Network
source · pub trait Network<PK: PublicKey, A: Data, D: Data>: Send + 'static {
// Required methods
fn add_connection(&mut self, peer: PK, address: A);
fn remove_connection(&mut self, peer: PK);
fn send(&self, data: D, recipient: PK);
fn next<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Option<D>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Network represents an interface for opening and closing connections with other nodes, and sending direct messages between them.
Note on Network reliability and security: it is neither assumed that the sent messages must be always delivered, nor the established connections must be secure in any way. The Network implementation might fail to deliver any specific message, so messages have to be resent while they still should be delivered.
Required Methods§
sourcefn add_connection(&mut self, peer: PK, address: A)
fn add_connection(&mut self, peer: PK, address: A)
Add the peer to the set of connected peers.
sourcefn remove_connection(&mut self, peer: PK)
fn remove_connection(&mut self, peer: PK)
Remove the peer from the set of connected peers and close the connection.