pub struct Endpoint { /* private fields */ }Expand description
Endpoint instance which can be used to communicate with peers.
Implementations§
Source§impl Endpoint
impl Endpoint
Sourcepub fn local_addr(&self) -> SocketAddr
pub fn local_addr(&self) -> SocketAddr
Endpoint local address
Sourcepub async fn connect_to(
&self,
node_addr: &SocketAddr,
) -> Result<(Connection, ConnectionIncoming), ConnectionError>
pub async fn connect_to( &self, node_addr: &SocketAddr, ) -> Result<(Connection, ConnectionIncoming), ConnectionError>
Connect to a peer.
Atttempts to connect to a peer at the given address.
Returns a Connection, which is a connection instance.
Note: this method is intended for use when it’s necessary to connect to a specific peer.
See connect_to_any if you just need a connection with any of a set
of peers.
Sourcepub async fn connect_to_any(
&self,
peer_addrs: &[SocketAddr],
) -> Option<(Connection, ConnectionIncoming)>
pub async fn connect_to_any( &self, peer_addrs: &[SocketAddr], ) -> Option<(Connection, ConnectionIncoming)>
Connect to any of the given peers.
Often in peer-to-peer networks, it’s sufficient to communicate to any node on the network,
rather than having to connect to specific nodes. This method will start connecting to every
peer in peer_addrs, and return the address of the first successfully established
connection (the rest are cancelled and discarded).
Sourcepub fn close(&self)
pub fn close(&self)
Close all the connections of this endpoint immediately and stop accepting new connections.
Sourcepub fn builder() -> EndpointBuilder
pub fn builder() -> EndpointBuilder
Builder to create an Endpoint.