Enum libp2p::swarm::SwarmEvent

source ·
pub enum SwarmEvent<TBehaviourOutEvent, THandlerErr> {
    Behaviour(TBehaviourOutEvent),
    ConnectionEstablished {
        peer_id: PeerId,
        endpoint: ConnectedPoint,
        num_established: NonZeroU32,
        concurrent_dial_errors: Option<Vec<(Multiaddr, TransportError<Error>), Global>>,
    },
    ConnectionClosed {
        peer_id: PeerId,
        endpoint: ConnectedPoint,
        num_established: u32,
        cause: Option<ConnectionError<THandlerErr>>,
    },
    IncomingConnection {
        local_addr: Multiaddr,
        send_back_addr: Multiaddr,
    },
    IncomingConnectionError {
        local_addr: Multiaddr,
        send_back_addr: Multiaddr,
        error: PendingConnectionError<TransportError<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, Global>,
        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.

§

ConnectionEstablished

Fields

§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>), Global>>

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.

A connection to the given peer has been opened.

§

ConnectionClosed

Fields

§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<THandlerErr>>

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

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

§

IncomingConnection

Fields

§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.

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.

§

IncomingConnectionError

Fields

§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: PendingConnectionError<TransportError<Error>>

The error that happened.

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.

§

OutgoingConnectionError

Fields

§peer_id: Option<PeerId>

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

§error: DialError

Error that has been encountered.

Outgoing connection attempt failed.

§

BannedPeer

Fields

§peer_id: PeerId

Identity of the banned peer.

§endpoint: ConnectedPoint

Endpoint of the connection that has been closed.

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

§

NewListenAddr

Fields

§listener_id: ListenerId

The listener that is listening on the new address.

§address: Multiaddr

The new address that is being listened on.

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

§

ExpiredListenAddr

Fields

§listener_id: ListenerId

The listener that is no longer listening on the address.

§address: Multiaddr

The expired address.

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

§

ListenerClosed

Fields

§listener_id: ListenerId

The listener that closed.

§addresses: Vec<Multiaddr, Global>

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.

One of the listeners gracefully closed.

§

ListenerError

Fields

§listener_id: ListenerId

The listener that errored.

§error: Error

The listener error.

One of the listeners reported a non-fatal error.

§

Dialing(PeerId)

A new dialing attempt has been initiated by the NetworkBehaviour implementation.

A ConnectionEstablished event is reported if the dialing attempt succeeds, otherwise a OutgoingConnectionError event is reported.

Trait Implementations§

source§

impl<TBehaviourOutEvent, THandlerErr> Debug for SwarmEvent<TBehaviourOutEvent, THandlerErr>where TBehaviourOutEvent: Debug, THandlerErr: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<TBehaviourOutEvent, THandlerErr> !RefUnwindSafe for SwarmEvent<TBehaviourOutEvent, THandlerErr>

§

impl<TBehaviourOutEvent, THandlerErr> Send for SwarmEvent<TBehaviourOutEvent, THandlerErr>where TBehaviourOutEvent: Send, THandlerErr: Send,

§

impl<TBehaviourOutEvent, THandlerErr> Sync for SwarmEvent<TBehaviourOutEvent, THandlerErr>where TBehaviourOutEvent: Sync, THandlerErr: Sync,

§

impl<TBehaviourOutEvent, THandlerErr> Unpin for SwarmEvent<TBehaviourOutEvent, THandlerErr>where TBehaviourOutEvent: Unpin, THandlerErr: Unpin,

§

impl<TBehaviourOutEvent, THandlerErr> !UnwindSafe for SwarmEvent<TBehaviourOutEvent, THandlerErr>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more