SwarmEvent

Enum SwarmEvent 

Source
pub enum SwarmEvent<TBvEv, THandleErr> {
Show 13 variants Behaviour(TBvEv), ConnectionEstablished { peer_id: PeerId, endpoint: ConnectedPoint, num_established: NonZeroU32, }, ConnectionClosed { peer_id: PeerId, endpoint: ConnectedPoint, num_established: u32, cause: Option<ConnectionError<NodeHandlerWrapperError<THandleErr>>>, }, IncomingConnection { local_addr: Multiaddr, send_back_addr: Multiaddr, }, IncomingConnectionError { local_addr: Multiaddr, send_back_addr: Multiaddr, error: PendingConnectionError<Error>, }, BannedPeer { peer_id: PeerId, endpoint: ConnectedPoint, }, UnreachableAddr { peer_id: PeerId, address: Multiaddr, error: PendingConnectionError<Error>, attempts_remaining: u32, }, UnknownPeerUnreachableAddr { address: Multiaddr, error: PendingConnectionError<Error>, }, NewListenAddr(Multiaddr), ExpiredListenAddr(Multiaddr), ListenerClosed { addresses: Vec<Multiaddr>, reason: Result<(), Error>, }, ListenerError { error: Error, }, Dialing(PeerId),
}
Expand description

Event generated by the Swarm.

Variants§

§

Behaviour(TBvEv)

Event generated by the NetworkBehaviour.

§

ConnectionEstablished

A connection to the given peer has been opened.

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.

§

ConnectionClosed

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

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<NodeHandlerWrapperError<THandleErr>>>

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

§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

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

The error that happened.

§

BannedPeer

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

Fields

§peer_id: PeerId

Identity of the banned peer.

§endpoint: ConnectedPoint

Endpoint of the connection that has been closed.

§

UnreachableAddr

Tried to dial an address but it ended up being unreachaable.

Fields

§peer_id: PeerId

PeerId that we were trying to reach.

§address: Multiaddr

Address that we failed to reach.

§error: PendingConnectionError<Error>

Error that has been encountered.

§attempts_remaining: u32

Number of remaining connection attempts that are being tried for this peer.

§

UnknownPeerUnreachableAddr

Tried to dial an address but it ended up being unreachaable. Contrary to UnreachableAddr, we don’t know the identity of the peer that we were trying to reach.

Fields

§address: Multiaddr

Address that we failed to reach.

§error: PendingConnectionError<Error>

Error that has been encountered.

§

NewListenAddr(Multiaddr)

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

§

ExpiredListenAddr(Multiaddr)

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

§

ListenerClosed

One of the listeners gracefully closed.

Fields

§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

§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 UnreachableAddr event is reported with attempts_remaining equal to 0.

Trait Implementations§

Source§

impl<TBvEv: Debug, THandleErr: Debug> Debug for SwarmEvent<TBvEv, THandleErr>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<TBvEv, THandleErr> Freeze for SwarmEvent<TBvEv, THandleErr>
where TBvEv: Freeze, THandleErr: Freeze,

§

impl<TBvEv, THandleErr> !RefUnwindSafe for SwarmEvent<TBvEv, THandleErr>

§

impl<TBvEv, THandleErr> Send for SwarmEvent<TBvEv, THandleErr>
where TBvEv: Send, THandleErr: Send,

§

impl<TBvEv, THandleErr> Sync for SwarmEvent<TBvEv, THandleErr>
where TBvEv: Sync, THandleErr: Sync,

§

impl<TBvEv, THandleErr> Unpin for SwarmEvent<TBvEv, THandleErr>
where TBvEv: Unpin, THandleErr: Unpin,

§

impl<TBvEv, THandleErr> !UnwindSafe for SwarmEvent<TBvEv, THandleErr>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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, U> Into<U> for T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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 T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,