Enum libp2p_swarm::SwarmEvent
source · #[non_exhaustive]pub enum SwarmEvent<TBehaviourOutEvent> {
Show 15 variants
Behaviour(TBehaviourOutEvent),
ConnectionEstablished {
peer_id: PeerId,
connection_id: ConnectionId,
endpoint: ConnectedPoint,
num_established: NonZeroU32,
concurrent_dial_errors: Option<Vec<(Multiaddr, TransportError<Error>)>>,
established_in: Duration,
},
ConnectionClosed {
peer_id: PeerId,
connection_id: ConnectionId,
endpoint: ConnectedPoint,
num_established: u32,
cause: Option<ConnectionError>,
},
IncomingConnection {
connection_id: ConnectionId,
local_addr: Multiaddr,
send_back_addr: Multiaddr,
},
IncomingConnectionError {
connection_id: ConnectionId,
local_addr: Multiaddr,
send_back_addr: Multiaddr,
error: ListenError,
},
OutgoingConnectionError {
connection_id: ConnectionId,
peer_id: Option<PeerId>,
error: DialError,
},
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 {
peer_id: Option<PeerId>,
connection_id: ConnectionId,
},
NewExternalAddrCandidate {
address: Multiaddr,
},
ExternalAddrConfirmed {
address: Multiaddr,
},
ExternalAddrExpired {
address: Multiaddr,
},
NewExternalAddrOfPeer {
peer_id: PeerId,
address: Multiaddr,
},
}
Expand description
Event generated by the Swarm
.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Behaviour(TBehaviourOutEvent)
Event generated by the NetworkBehaviour
.
ConnectionEstablished
A connection to the given peer has been opened.
Fields
connection_id: ConnectionId
Identifier of the connection.
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
connection_id: ConnectionId
Identifier of the connection.
endpoint: ConnectedPoint
Endpoint of the connection that has been closed.
cause: Option<ConnectionError>
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
or
IncomingConnectionError
event will later be
generated for this connection.
Fields
connection_id: ConnectionId
Identifier of the connection.
local_addr: Multiaddr
Local connection address.
This address has been earlier reported with a NewListenAddr
event.
IncomingConnectionError
An error happened on an inbound 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
connection_id: ConnectionId
Identifier of the connection.
local_addr: Multiaddr
Local connection address.
This address has been earlier reported with a NewListenAddr
event.
error: ListenError
The error that happened.
OutgoingConnectionError
An error happened on an outbound connection.
Fields
connection_id: ConnectionId
Identifier of the connection.
NewListenAddr
One of our listeners has reported a new local listening address.
Fields
listener_id: ListenerId
The listener that is listening on the new address.
ExpiredListenAddr
One of our listeners has reported the expiration of a listening address.
Fields
listener_id: ListenerId
The listener that is no longer listening on the address.
ListenerClosed
One of the listeners gracefully closed.
Fields
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.
ListenerError
One of the listeners reported a non-fatal error.
Dialing
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.
Fields
connection_id: ConnectionId
Identifier of the connection.
NewExternalAddrCandidate
We have discovered a new candidate for an external address for us.
ExternalAddrConfirmed
An external address of the local node was confirmed.
ExternalAddrExpired
An external address of the local node expired, i.e. is no-longer confirmed.
NewExternalAddrOfPeer
We have discovered a new address of a peer.
Implementations§
source§impl<TBehaviourOutEvent> SwarmEvent<TBehaviourOutEvent>
impl<TBehaviourOutEvent> SwarmEvent<TBehaviourOutEvent>
sourcepub fn try_into_behaviour_event(self) -> Result<TBehaviourOutEvent, Self>
pub fn try_into_behaviour_event(self) -> Result<TBehaviourOutEvent, Self>
Extract the TBehaviourOutEvent
from this SwarmEvent
in case it is the Behaviour
variant, otherwise fail.
Trait Implementations§
Auto Trait Implementations§
impl<TBehaviourOutEvent> Freeze for SwarmEvent<TBehaviourOutEvent>where
TBehaviourOutEvent: Freeze,
impl<TBehaviourOutEvent> !RefUnwindSafe for SwarmEvent<TBehaviourOutEvent>
impl<TBehaviourOutEvent> Send for SwarmEvent<TBehaviourOutEvent>where
TBehaviourOutEvent: Send,
impl<TBehaviourOutEvent> Sync for SwarmEvent<TBehaviourOutEvent>where
TBehaviourOutEvent: Sync,
impl<TBehaviourOutEvent> Unpin for SwarmEvent<TBehaviourOutEvent>where
TBehaviourOutEvent: Unpin,
impl<TBehaviourOutEvent> !UnwindSafe for SwarmEvent<TBehaviourOutEvent>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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