Enum libp2p_core::network::peer::Peer[][src]

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.

Tuple Fields of Connected

0: ConnectedPeer<'a, TTrans, THandler>
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.

Tuple Fields of Dialing

0: DialingPeer<'a, TTrans, THandler>
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.

Tuple Fields of Disconnected

0: DisconnectedPeer<'a, TTrans, THandler>
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

Performs the conversion.

Performs the conversion.

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.