pub struct TcpNetwork { /* private fields */ }Expand description
TCP Network implementation
Implementations§
Source§impl TcpNetwork
impl TcpNetwork
Sourcepub async fn new(node_id: NodeId, config: TcpNetworkConfig) -> Result<Self>
pub async fn new(node_id: NodeId, config: TcpNetworkConfig) -> Result<Self>
Create a new TCP network instance
Sourcepub async fn connect_to_peer(
&self,
peer_node_id: NodeId,
addr: SocketAddr,
) -> Result<()>
pub async fn connect_to_peer( &self, peer_node_id: NodeId, addr: SocketAddr, ) -> Result<()>
Connect to a peer node
Sourcepub fn local_addr(&self) -> SocketAddr
pub fn local_addr(&self) -> SocketAddr
Get the local bind address
Sourcepub async fn add_peer(&mut self, node_id: NodeId, addr: SocketAddr)
pub async fn add_peer(&mut self, node_id: NodeId, addr: SocketAddr)
Add a known peer address for automatic connection
Sourcepub async fn remove_peer(&mut self, node_id: NodeId)
pub async fn remove_peer(&mut self, node_id: NodeId)
Remove a peer
Trait Implementations§
Source§impl Clone for TcpNetwork
impl Clone for TcpNetwork
Source§impl NetworkTransport for TcpNetwork
impl NetworkTransport for TcpNetwork
fn send_to<'life0, 'async_trait>(
&'life0 self,
target: NodeId,
message: ProtocolMessage,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn broadcast<'life0, 'async_trait>(
&'life0 self,
message: ProtocolMessage,
exclude: Option<NodeId>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn receive<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(NodeId, ProtocolMessage)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_connected_nodes<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<HashSet<NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_connected<'life0, 'async_trait>(
&'life0 self,
node_id: NodeId,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !Freeze for TcpNetwork
impl !RefUnwindSafe for TcpNetwork
impl Send for TcpNetwork
impl Sync for TcpNetwork
impl Unpin for TcpNetwork
impl UnsafeUnpin for TcpNetwork
impl !UnwindSafe for TcpNetwork
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more