libp2p::swarm

Enum SwarmEvent

#[non_exhaustive]
pub enum SwarmEvent<TBehaviourOutEvent> {
Show 15 variants Behaviour(TBehaviourOutEvent), ConnectionEstablished { peer_id: PeerId, connection_id: ConnectionId, endpoint: ConnectedPoint, num_established: NonZero<u32>, 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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Behaviour(TBehaviourOutEvent)

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.

§connection_id: ConnectionId

Identifier of the connection.

§endpoint: ConnectedPoint

Endpoint of the connection that has been opened.

§num_established: NonZero<u32>

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.

§established_in: Duration

How long it took to establish this connection

§

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.

§connection_id: ConnectionId

Identifier of the connection.

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

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.

§send_back_addr: Multiaddr

Address used to send back data to the remote.

§

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.

§send_back_addr: Multiaddr

Address used to send back data to the remote.

§error: ListenError

The error that happened.

§

OutgoingConnectionError

An error happened on an outbound connection.

Fields

§connection_id: ConnectionId

Identifier of the connection.

§peer_id: Option<PeerId>

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

§error: DialError

Error that has been encountered.

§

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.

§address: Multiaddr

The new address that is being listened on.

§

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.

§address: Multiaddr

The expired 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.

§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

§listener_id: ListenerId

The listener that errored.

§error: Error

The listener 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

§peer_id: Option<PeerId>

Identity of the peer that we are connecting to.

§connection_id: ConnectionId

Identifier of the connection.

§

NewExternalAddrCandidate

We have discovered a new candidate for an external address for us.

Fields

§address: Multiaddr
§

ExternalAddrConfirmed

An external address of the local node was confirmed.

Fields

§address: Multiaddr
§

ExternalAddrExpired

An external address of the local node expired, i.e. is no-longer confirmed.

Fields

§address: Multiaddr
§

NewExternalAddrOfPeer

We have discovered a new address of a peer.

Fields

§peer_id: PeerId
§address: Multiaddr

Implementations§

§

impl<TBehaviourOutEvent> SwarmEvent<TBehaviourOutEvent>

pub fn try_into_behaviour_event( self, ) -> Result<TBehaviourOutEvent, SwarmEvent<TBehaviourOutEvent>>

Extract the TBehaviourOutEvent from this SwarmEvent in case it is the Behaviour variant, otherwise fail.

Trait Implementations§

§

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

§

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

Formats the value using the given formatter. Read more
Source§

impl<TBvEv> Recorder<SwarmEvent<TBvEv>> for Metrics

Source§

fn record(&self, event: &SwarmEvent<TBvEv>)

Record the given event.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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.

§

impl<T> Instrument for T

§

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

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

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

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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