logo
pub enum Peer<'a, TTrans, TInEvent, TOutEvent, THandler> where
    TTrans: Transport,
    THandler: IntoConnectionHandler
{ Connected(ConnectedPeer<'a, TTrans, TInEvent, TOutEvent, THandler>), Dialing(DialingPeer<'a, TTrans, TInEvent, TOutEvent, THandler>), Disconnected(DisconnectedPeer<'a, TTrans, TInEvent, TOutEvent, 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, TInEvent, TOutEvent, THandler>)

At least one established connection exists to the peer.

Dialing(DialingPeer<'a, TTrans, TInEvent, TOutEvent, 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, TInEvent, TOutEvent, 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

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.

Initiates a new dialing attempt to this peer using the given addresses.

The connection ID of the first connection attempt, i.e. to address, is returned, together with a DialingPeer for further use. The remaining addresses are tried in order in subsequent connection attempts in the context of the same dialing attempt, if the connection attempt to the first address fails.

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.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.