Enum libp2p_swarm::SwarmEvent[][src]

pub enum SwarmEvent<TBehaviourOutEvent, THandlerErr> {
    Behaviour(TBehaviourOutEvent),
    ConnectionEstablished {
        peer_id: PeerId,
        endpoint: ConnectedPoint,
        num_established: NonZeroU32,
        concurrent_dial_errors: Option<Vec<(Multiaddr, TransportError<Error>)>>,
    },
    ConnectionClosed {
        peer_id: PeerId,
        endpoint: ConnectedPoint,
        num_established: u32,
        cause: Option<ConnectionError<NodeHandlerWrapperError<THandlerErr>>>,
    },
    IncomingConnection {
        local_addr: Multiaddr,
        send_back_addr: Multiaddr,
    },
    IncomingConnectionError {
        local_addr: Multiaddr,
        send_back_addr: Multiaddr,
        error: PendingInboundConnectionError<Error>,
    },
    OutgoingConnectionError {
        peer_id: Option<PeerId>,
        error: DialError,
    },
    BannedPeer {
        peer_id: PeerId,
        endpoint: ConnectedPoint,
    },
    NewListenAddr {
        listener_id: ListenerId,
        address: Multiaddr,
    },
    ExpiredListenAddr {
        listener_id: ListenerId,
        address: Multiaddr,
    },
    ListenerClosed {
        listener_id: ListenerId,
        addresses: Vec<Multiaddr>,
        reason: Result<(), Error>,
    },
    ListenerError {
        listener_id: ListenerId,
        error: Error,
    },
    Dialing(PeerId),
}
Expand description

Event generated by the Swarm.

Variants

Behaviour(TBehaviourOutEvent)

Event generated by the NetworkBehaviour.

Tuple Fields of Behaviour

0: TBehaviourOutEvent
ConnectionEstablished

A connection to the given peer has been opened.

Fields of ConnectionEstablished

peer_id: PeerId

Identity of the peer that we have connected to.

endpoint: ConnectedPoint

Endpoint of the connection that has been opened.

num_established: NonZeroU32

Number of established connections to this peer, including the one that has just been opened.

concurrent_dial_errors: Option<Vec<(Multiaddr, TransportError<Error>)>>

Some when the new connection is an outgoing connection. Addresses are dialed concurrently. Contains the addresses and errors of dial attempts that failed before the one successful dial.

ConnectionClosed

A connection with the given peer has been closed, possibly as a result of an error.

Fields of ConnectionClosed

peer_id: PeerId

Identity of the peer that we have connected to.

endpoint: ConnectedPoint

Endpoint of the connection that has been closed.

num_established: u32

Number of other remaining connections to this same peer.

cause: Option<ConnectionError<NodeHandlerWrapperError<THandlerErr>>>

Reason for the disconnection, if it was not a successful active close.

IncomingConnection

A new connection arrived on a listener and is in the process of protocol negotiation.

A corresponding ConnectionEstablished, BannedPeer, or IncomingConnectionError event will later be generated for this connection.

Fields of IncomingConnection

local_addr: Multiaddr

Local connection address. This address has been earlier reported with a NewListenAddr event.

send_back_addr: Multiaddr

Address used to send back data to the remote.

IncomingConnectionError

An error happened on a connection during its initial handshake.

This can include, for example, an error during the handshake of the encryption layer, or the connection unexpectedly closed.

Fields of IncomingConnectionError

local_addr: Multiaddr

Local connection address. This address has been earlier reported with a NewListenAddr event.

send_back_addr: Multiaddr

Address used to send back data to the remote.

error: PendingInboundConnectionError<Error>

The error that happened.

OutgoingConnectionError

Outgoing connection attempt failed.

Fields of OutgoingConnectionError

peer_id: Option<PeerId>

If known, PeerId of the peer we tried to reach.

error: DialError

Error that has been encountered.

BannedPeer

We connected to a peer, but we immediately closed the connection because that peer is banned.

Fields of BannedPeer

peer_id: PeerId

Identity of the banned peer.

endpoint: ConnectedPoint

Endpoint of the connection that has been closed.

NewListenAddr

One of our listeners has reported a new local listening address.

Fields of NewListenAddr

listener_id: ListenerId

The listener that is listening on the new address.

address: Multiaddr

The new address that is being listened on.

ExpiredListenAddr

One of our listeners has reported the expiration of a listening address.

Fields of ExpiredListenAddr

listener_id: ListenerId

The listener that is no longer listening on the address.

address: Multiaddr

The expired address.

ListenerClosed

One of the listeners gracefully closed.

Fields of ListenerClosed

listener_id: ListenerId

The listener that closed.

addresses: Vec<Multiaddr>

The addresses that the listener was listening on. These addresses are now considered expired, similar to if a ExpiredListenAddr event has been generated for each of them.

reason: Result<(), Error>

Reason for the closure. Contains Ok(()) if the stream produced None, or Err if the stream produced an error.

ListenerError

One of the listeners reported a non-fatal error.

Fields of ListenerError

listener_id: ListenerId

The listener that errored.

error: Error

The listener error.

Dialing(PeerId)

A new dialing attempt has been initiated.

A ConnectionEstablished event is reported if the dialing attempt succeeds, otherwise a OutgoingConnectionError event is reported with attempts_remaining equal to 0.

Tuple Fields of Dialing

0: PeerId

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.