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.
ListenerError
One of the listeners reported a non-fatal 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.
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.
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
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
- it encounters an error, which includes the connection being
closed by the remote. In this case
error
isSome
. - it was actively closed by
EstablishedConnection::start_close
, i.e. a successful, orderly close. In this caseerror
isNone
. - it was actively closed by
super::peer::ConnectedPeer::disconnect
orsuper::peer::DialingPeer::disconnect
, i.e. dropped without an orderly close. In this caseerror
isNone
.
Fields
id: ConnectionId
The ID of the connection that encountered an error.
error: Option<ConnectionError<<THandler::Handler as ConnectionHandler>::Error>>
The error that occurred.
DialError
A dialing attempt to an address of a peer failed.
Fields
error: PendingConnectionError<TTrans::Error>
The error that happened.
UnknownPeerDialError
Failed to reach a peer that we were trying to dial.
Fields
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,
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,
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> 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> 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