pub enum Peer<'a, TTrans, THandler> where
TTrans: Transport,
THandler: IntoConnectionHandler, {
Connected(ConnectedPeer<'a, TTrans, THandler>),
Dialing(DialingPeer<'a, TTrans, THandler>),
Disconnected(DisconnectedPeer<'a, TTrans, THandler>),
Local,
}Expand description
The possible representations of a peer in a Network, as
seen by the local node.
Note: In any state there may always be a pending incoming connection attempt from the peer, however, the remote identity of a peer is only known once a connection is fully established.
Variants
Connected(ConnectedPeer<'a, TTrans, THandler>)
At least one established connection exists to the peer.
Dialing(DialingPeer<'a, TTrans, THandler>)
There is an ongoing dialing (i.e. outgoing connection) attempt to the peer. There may already be other established connections to the peer.
Disconnected(DisconnectedPeer<'a, TTrans, THandler>)
There exists no established connection to the peer and there is currently no ongoing dialing (i.e. outgoing connection) attempt in progress.
Local
The peer represents the local node.
Implementations
impl<'a, TTrans, THandler> Peer<'a, TTrans, THandler> where
TTrans: Transport + Clone + Send + 'static,
TTrans::Output: Send + 'static,
TTrans::Error: Send + 'static,
TTrans::Dial: Send + 'static,
THandler: IntoConnectionHandler + Send + 'static,
THandler::Handler: ConnectionHandler + Send,
<THandler::Handler as ConnectionHandler>::OutboundOpenInfo: Send,
<THandler::Handler as ConnectionHandler>::Error: Error + Send + 'static,
impl<'a, TTrans, THandler> Peer<'a, TTrans, THandler> where
TTrans: Transport + Clone + Send + 'static,
TTrans::Output: Send + 'static,
TTrans::Error: Send + 'static,
TTrans::Dial: Send + 'static,
THandler: IntoConnectionHandler + Send + 'static,
THandler::Handler: ConnectionHandler + Send,
<THandler::Handler as ConnectionHandler>::OutboundOpenInfo: Send,
<THandler::Handler as ConnectionHandler>::Error: Error + Send + 'static,
Checks whether the peer is currently connected.
Returns true iff Peer::into_connected returns Some.
Checks whether the peer is currently being dialed.
Returns true iff Peer::into_dialing returns Some.
Checks whether the peer is currently disconnected.
Returns true iff Peer::into_disconnected returns Some.
Converts the peer into a ConnectedPeer, if an established connection exists.
Succeeds if the there is at least one established connection to the peer.
Converts the peer into a DialingPeer, if a dialing attempt exists.
Succeeds if the there is at least one pending outgoing connection to the peer.
Converts the peer into a DisconnectedPeer, if neither an established connection
nor a dialing attempt exists.