pub struct PeerConnectionState {Show 15 fields
pub node_id: NodeId,
pub identifier: String,
pub state: ConnectionState,
pub discovered_at: u64,
pub connected_at: Option<u64>,
pub disconnected_at: Option<u64>,
pub disconnect_reason: Option<DisconnectReason>,
pub last_rssi: Option<i8>,
pub connection_count: u32,
pub documents_synced: u32,
pub bytes_received: u64,
pub bytes_sent: u64,
pub last_seen_ms: u64,
pub name: Option<String>,
pub mesh_id: Option<String>,
}Expand description
Per-peer connection state with history
Provides a comprehensive view of a peer’s connection lifecycle, including timestamps, statistics, and associated data metrics. This enables apps to display appropriate UI indicators and track data provenance.
Fields§
§node_id: NodeIdHIVE node identifier
identifier: StringPlatform-specific BLE identifier
state: ConnectionStateCurrent connection state
discovered_at: u64Timestamp when peer was first discovered (ms since epoch)
connected_at: Option<u64>Timestamp of most recent connection (ms since epoch)
disconnected_at: Option<u64>Timestamp of most recent disconnection (ms since epoch)
disconnect_reason: Option<DisconnectReason>Reason for most recent disconnection
last_rssi: Option<i8>Most recent RSSI reading (dBm)
connection_count: u32Total number of successful connections to this peer
documents_synced: u32Number of documents synced with this peer
bytes_received: u64Bytes received from this peer
bytes_sent: u64Bytes sent to this peer
last_seen_ms: u64Last time peer was seen (advertisement or data, ms since epoch)
name: Option<String>Optional device name
mesh_id: Option<String>Mesh ID this peer belongs to
Implementations§
Source§impl PeerConnectionState
impl PeerConnectionState
Sourcepub fn new_discovered(node_id: NodeId, identifier: String, now_ms: u64) -> Self
pub fn new_discovered(node_id: NodeId, identifier: String, now_ms: u64) -> Self
Create a new connection state for a discovered peer
Sourcepub fn set_connecting(&mut self, now_ms: u64)
pub fn set_connecting(&mut self, now_ms: u64)
Transition to connecting state
Sourcepub fn set_connected(&mut self, now_ms: u64)
pub fn set_connected(&mut self, now_ms: u64)
Transition to connected state
Sourcepub fn set_degraded(&mut self, now_ms: u64)
pub fn set_degraded(&mut self, now_ms: u64)
Transition to degraded state (still connected but poor quality)
Sourcepub fn set_disconnected(&mut self, now_ms: u64, reason: DisconnectReason)
pub fn set_disconnected(&mut self, now_ms: u64, reason: DisconnectReason)
Transition to disconnected state
Sourcepub fn update_rssi(
&mut self,
rssi: i8,
now_ms: u64,
degraded_threshold: i8,
) -> bool
pub fn update_rssi( &mut self, rssi: i8, now_ms: u64, degraded_threshold: i8, ) -> bool
Update RSSI and check for degradation
Returns true if state changed to Degraded
Sourcepub fn record_transfer(&mut self, bytes_received: u64, bytes_sent: u64)
pub fn record_transfer(&mut self, bytes_received: u64, bytes_sent: u64)
Record data transfer statistics
Sourcepub fn record_sync(&mut self)
pub fn record_sync(&mut self)
Record a document sync
Sourcepub fn time_since_connected(&self, now_ms: u64) -> Option<u64>
pub fn time_since_connected(&self, now_ms: u64) -> Option<u64>
Get time since last connection (if ever connected)
Sourcepub fn time_since_disconnected(&self, now_ms: u64) -> Option<u64>
pub fn time_since_disconnected(&self, now_ms: u64) -> Option<u64>
Get time since disconnection (if disconnected)
Sourcepub fn connection_duration(&self, now_ms: u64) -> Option<u64>
pub fn connection_duration(&self, now_ms: u64) -> Option<u64>
Get connection duration if currently connected
Sourcepub fn signal_strength(&self) -> Option<SignalStrength>
pub fn signal_strength(&self) -> Option<SignalStrength>
Get signal strength category
Trait Implementations§
Source§impl Clone for PeerConnectionState
impl Clone for PeerConnectionState
Source§fn clone(&self) -> PeerConnectionState
fn clone(&self) -> PeerConnectionState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more