Enum NetworkEvent

Source
pub enum NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler>
where TTrans: Transport, THandler: IntoConnectionHandler,
{ ListenerClosed { listener_id: ListenerId, addresses: Vec<Multiaddr>, reason: Result<(), TTrans::Error>, }, ListenerError { listener_id: ListenerId, error: TTrans::Error, }, NewListenerAddress { listener_id: ListenerId, listen_addr: Multiaddr, }, ExpiredListenerAddress { listener_id: ListenerId, listen_addr: Multiaddr, }, IncomingConnection { listener_id: ListenerId, connection: IncomingConnection<TTrans::ListenerUpgrade>, }, IncomingConnectionError { local_addr: Multiaddr, send_back_addr: Multiaddr, error: PendingConnectionError<TTrans::Error>, }, ConnectionEstablished { connection: EstablishedConnection<'a, TInEvent>, num_established: NonZeroU32, }, ConnectionClosed { id: ConnectionId, connected: Connected, error: Option<ConnectionError<<THandler::Handler as ConnectionHandler>::Error>>, num_established: u32, }, DialError { attempts_remaining: u32, peer_id: PeerId, multiaddr: Multiaddr, error: PendingConnectionError<TTrans::Error>, }, UnknownPeerDialError { multiaddr: Multiaddr, error: PendingConnectionError<TTrans::Error>, }, ConnectionEvent { connection: EstablishedConnection<'a, TInEvent>, event: TOutEvent, }, AddressChange { connection: EstablishedConnection<'a, TInEvent>, new_endpoint: ConnectedPoint, old_endpoint: ConnectedPoint, }, }
Expand description

Event that can happen on the Network.

Variants§

§

ListenerClosed

One of the listeners gracefully closed.

Fields

§listener_id: ListenerId

The listener ID that closed.

§addresses: Vec<Multiaddr>

The addresses that the listener was listening on.

§reason: Result<(), TTrans::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: TTrans::Error

The listener error.

§

NewListenerAddress

One of the listeners is now listening on an additional address.

Fields

§listener_id: ListenerId

The listener that is listening on the new address.

§listen_addr: Multiaddr

The new address the listener is now also listening on.

§

ExpiredListenerAddress

One of the listeners is no longer listening on some address.

Fields

§listener_id: ListenerId

The listener that is no longer listening on some address.

§listen_addr: Multiaddr

The expired address.

§

IncomingConnection

A new connection arrived on a listener.

To accept the connection, see Network::accept.

Fields

§listener_id: ListenerId

The listener who received the connection.

§connection: IncomingConnection<TTrans::ListenerUpgrade>

The pending incoming connection.

§

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.

§send_back_addr: Multiaddr

Address used to send back data to the remote.

§error: PendingConnectionError<TTrans::Error>

The error that happened.

§

ConnectionEstablished

A new connection to a peer has been established.

Fields

§connection: EstablishedConnection<'a, TInEvent>

The newly established connection.

§num_established: NonZeroU32

The total number of established connections to the same peer, including the one that has just been opened.

§

ConnectionClosed

An established connection to a peer has been closed.

A connection may close if

Fields

§id: ConnectionId

The ID of the connection that encountered an error.

§connected: Connected

Information about the connection that encountered the error.

§error: Option<ConnectionError<<THandler::Handler as ConnectionHandler>::Error>>

The error that occurred.

§num_established: u32

The remaining number of established connections to the same peer.

§

DialError

A dialing attempt to an address of a peer failed.

Fields

§attempts_remaining: u32

The number of remaining dialing attempts.

§peer_id: PeerId

Id of the peer we were trying to dial.

§multiaddr: Multiaddr

The multiaddr we failed to reach.

§error: PendingConnectionError<TTrans::Error>

The error that happened.

§

UnknownPeerDialError

Failed to reach a peer that we were trying to dial.

Fields

§multiaddr: Multiaddr

The multiaddr we failed to reach.

§error: PendingConnectionError<TTrans::Error>

The error that happened.

§

ConnectionEvent

An established connection produced an event.

Fields

§connection: EstablishedConnection<'a, TInEvent>

The connection on which the event occurred.

§event: TOutEvent

Event that was produced by the node.

§

AddressChange

An established connection has changed its address.

Fields

§connection: EstablishedConnection<'a, TInEvent>

The connection whose address has changed.

§new_endpoint: ConnectedPoint

New endpoint of this connection.

§old_endpoint: ConnectedPoint

Old endpoint of this connection.

Trait Implementations§

Source§

impl<TTrans, TInEvent, TOutEvent, THandler> Debug for NetworkEvent<'_, TTrans, TInEvent, TOutEvent, THandler>
where TInEvent: Debug, TOutEvent: Debug, TTrans: Transport, TTrans::Error: Debug, THandler: IntoConnectionHandler, <THandler::Handler as ConnectionHandler>::Error: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, TTrans, TInEvent, TOutEvent, THandler> Freeze for NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler>
where <TTrans as Transport>::Error: Freeze, TOutEvent: Freeze, <TTrans as Transport>::ListenerUpgrade: Freeze, <<THandler as IntoConnectionHandler>::Handler as ConnectionHandler>::Error: Freeze,

§

impl<'a, TTrans, TInEvent, TOutEvent, THandler> !RefUnwindSafe for NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler>

§

impl<'a, TTrans, TInEvent, TOutEvent, THandler> Send for NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler>
where <TTrans as Transport>::Error: Send, TOutEvent: Send, <TTrans as Transport>::ListenerUpgrade: Send, <<THandler as IntoConnectionHandler>::Handler as ConnectionHandler>::Error: Send, TInEvent: Send,

§

impl<'a, TTrans, TInEvent, TOutEvent, THandler> Sync for NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler>
where <TTrans as Transport>::Error: Sync, TOutEvent: Sync, <TTrans as Transport>::ListenerUpgrade: Sync, <<THandler as IntoConnectionHandler>::Handler as ConnectionHandler>::Error: Sync, TInEvent: Send,

§

impl<'a, TTrans, TInEvent, TOutEvent, THandler> Unpin for NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler>
where <TTrans as Transport>::Error: Unpin, TOutEvent: Unpin, <TTrans as Transport>::ListenerUpgrade: Unpin, <<THandler as IntoConnectionHandler>::Handler as ConnectionHandler>::Error: Unpin,

§

impl<'a, TTrans, TInEvent, TOutEvent, THandler> !UnwindSafe for NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler>

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,