pub enum NodeEvent {
PeerConnected {
peer_id: PeerId,
addr: TransportAddr,
direct: bool,
},
PeerDisconnected {
peer_id: PeerId,
reason: DisconnectReason,
},
ConnectionFailed {
addr: SocketAddr,
error: String,
},
ExternalAddressDiscovered {
addr: TransportAddr,
},
NatTypeDetected {
nat_type: NatType,
},
NatTraversalComplete {
peer_id: PeerId,
success: bool,
method: TraversalMethod,
},
RelaySessionStarted {
peer_id: PeerId,
},
RelaySessionEnded {
peer_id: PeerId,
bytes_forwarded: u64,
},
CoordinationStarted {
peer_a: PeerId,
peer_b: PeerId,
},
CoordinationComplete {
peer_a: PeerId,
peer_b: PeerId,
success: bool,
},
DataReceived {
peer_id: PeerId,
stream_id: u64,
bytes: usize,
},
DataSent {
peer_id: PeerId,
stream_id: u64,
bytes: usize,
},
}Expand description
Unified event type for all node activities
Subscribe to these events via node.subscribe() to monitor
all significant node activities in real-time.
Variants§
PeerConnected
A peer connected successfully
Fields
addr: TransportAddrThe peer’s address (supports all transport types)
PeerDisconnected
A peer disconnected
ConnectionFailed
Connection attempt failed
ExternalAddressDiscovered
External address discovered
This is the address as seen by other peers.
Fields
addr: TransportAddrThe discovered external address (supports all transport types)
NatTypeDetected
NAT type detected
NatTraversalComplete
NAT traversal completed
Fields
method: TraversalMethodConnection method used
RelaySessionStarted
Started relaying for a peer
RelaySessionEnded
Stopped relaying for a peer
Fields
CoordinationStarted
Started coordinating NAT traversal for peers
CoordinationComplete
NAT traversal coordination completed
Fields
DataReceived
Data received from a peer
Fields
DataSent
Data sent to a peer
Implementations§
Source§impl NodeEvent
impl NodeEvent
Sourcepub fn is_connection_event(&self) -> bool
pub fn is_connection_event(&self) -> bool
Check if this is a connection event
Sourcepub fn is_nat_event(&self) -> bool
pub fn is_nat_event(&self) -> bool
Check if this is a NAT-related event
Sourcepub fn is_relay_event(&self) -> bool
pub fn is_relay_event(&self) -> bool
Check if this is a relay event
Sourcepub fn is_coordination_event(&self) -> bool
pub fn is_coordination_event(&self) -> bool
Check if this is a coordination event
Sourcepub fn is_data_event(&self) -> bool
pub fn is_data_event(&self) -> bool
Check if this is a data event