PeerConnectionState

Struct PeerConnectionState 

Source
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: NodeId

HIVE node identifier

§identifier: String

Platform-specific BLE identifier

§state: ConnectionState

Current connection state

§discovered_at: u64

Timestamp 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: u32

Total number of successful connections to this peer

§documents_synced: u32

Number of documents synced with this peer

§bytes_received: u64

Bytes received from this peer

§bytes_sent: u64

Bytes sent to this peer

§last_seen_ms: u64

Last 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

Source

pub fn new_discovered(node_id: NodeId, identifier: String, now_ms: u64) -> Self

Create a new connection state for a discovered peer

Source

pub fn from_peer(peer: &HivePeer, now_ms: u64) -> Self

Create from an existing HivePeer

Source

pub fn set_connecting(&mut self, now_ms: u64)

Transition to connecting state

Source

pub fn set_connected(&mut self, now_ms: u64)

Transition to connected state

Source

pub fn set_degraded(&mut self, now_ms: u64)

Transition to degraded state (still connected but poor quality)

Source

pub fn set_disconnected(&mut self, now_ms: u64, reason: DisconnectReason)

Transition to disconnected state

Source

pub fn set_lost(&mut self, now_ms: u64)

Transition to lost state (not seen in advertisements)

Source

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

Source

pub fn record_transfer(&mut self, bytes_received: u64, bytes_sent: u64)

Record data transfer statistics

Source

pub fn record_sync(&mut self)

Record a document sync

Source

pub fn time_since_connected(&self, now_ms: u64) -> Option<u64>

Get time since last connection (if ever connected)

Source

pub fn time_since_disconnected(&self, now_ms: u64) -> Option<u64>

Get time since disconnection (if disconnected)

Source

pub fn connection_duration(&self, now_ms: u64) -> Option<u64>

Get connection duration if currently connected

Source

pub fn signal_strength(&self) -> Option<SignalStrength>

Get signal strength category

Trait Implementations§

Source§

impl Clone for PeerConnectionState

Source§

fn clone(&self) -> PeerConnectionState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PeerConnectionState

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.