pub enum NodeEvent {
PeerConnected {
peer_id: PeerId,
addr: SocketAddr,
direct: bool,
},
PeerDisconnected {
peer_id: PeerId,
reason: DisconnectReason,
},
ConnectionFailed {
addr: SocketAddr,
error: String,
},
ExternalAddressDiscovered {
addr: SocketAddr,
},
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: SocketAddrThe peer’s address
PeerDisconnected
A peer disconnected
ConnectionFailed
Connection attempt failed
ExternalAddressDiscovered
External address discovered
This is the address as seen by other peers.
Fields
§
addr: SocketAddrThe discovered external address
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
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NodeEvent
impl RefUnwindSafe for NodeEvent
impl Send for NodeEvent
impl Sync for NodeEvent
impl Unpin for NodeEvent
impl UnwindSafe for NodeEvent
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
Mutably borrows from an owned value. Read more