pub struct Tcp(/* private fields */);
Expand description
The central object responsible for handling connections.
Implementations§
Source§impl Tcp
impl Tcp
Sourcepub fn listening_addr(&self) -> Result<SocketAddr>
pub fn listening_addr(&self) -> Result<SocketAddr>
Returns the listening address; returns an error if Tcp was not configured to listen for inbound connections.
Sourcepub fn is_connected(&self, addr: SocketAddr) -> bool
pub fn is_connected(&self, addr: SocketAddr) -> bool
Checks whether the provided address is connected.
Sourcepub fn is_connecting(&self, addr: SocketAddr) -> bool
pub fn is_connecting(&self, addr: SocketAddr) -> bool
Checks if Tcp is currently setting up a connection with the provided address.
Sourcepub fn num_connected(&self) -> usize
pub fn num_connected(&self) -> usize
Returns the number of active connections.
Sourcepub fn num_connecting(&self) -> usize
pub fn num_connecting(&self) -> usize
Returns the number of connections that are currently being set up.
Sourcepub fn connected_addrs(&self) -> Vec<SocketAddr>
pub fn connected_addrs(&self) -> Vec<SocketAddr>
Returns a list containing addresses of active connections.
Sourcepub fn connecting_addrs(&self) -> Vec<SocketAddr>
pub fn connecting_addrs(&self) -> Vec<SocketAddr>
Returns a list containing addresses of pending connections.
Sourcepub fn known_peers(&self) -> &KnownPeers
pub fn known_peers(&self) -> &KnownPeers
Returns a reference to the collection of statistics of known peers.
Sourcepub fn banned_peers(&self) -> &BannedPeers
pub fn banned_peers(&self) -> &BannedPeers
Returns a reference to the set of currently banned peers.
Source§impl Tcp
impl Tcp
Sourcepub async fn connect(&self, addr: SocketAddr) -> Result<(), ConnectError>
pub async fn connect(&self, addr: SocketAddr) -> Result<(), ConnectError>
Connects to the provided SocketAddr
.
Sourcepub async fn disconnect(&self, addr: SocketAddr) -> bool
pub async fn disconnect(&self, addr: SocketAddr) -> bool
Disconnects from the provided SocketAddr
.
Returns true if the we were connected to the given address.
Source§impl Tcp
impl Tcp
Sourcepub async fn enable_listener(&self) -> Result<SocketAddr>
pub async fn enable_listener(&self) -> Result<SocketAddr>
Spawns a task that listens for incoming connections.