pub struct PeerConnectionInfo {
pub peer_id: String,
pub address: String,
pub state: ConnectionState,
pub connected_at_secs: Option<u64>,
pub disconnected_at_secs: Option<u64>,
pub protocols: Vec<String>,
pub ping_count: u64,
pub ping_failures: u64,
pub avg_rtt_ms: f64,
}Expand description
All tracked information for a single peer.
Fields§
§peer_id: StringUnique peer identifier.
address: StringMost recent address used by the peer.
state: ConnectionStateCurrent connection state.
connected_at_secs: Option<u64>Unix timestamp (seconds) when the connection was first established.
disconnected_at_secs: Option<u64>Unix timestamp (seconds) when the connection was last terminated.
protocols: Vec<String>Protocols negotiated with this peer.
ping_count: u64Total number of ping attempts (successes + failures).
ping_failures: u64Number of failed ping attempts.
avg_rtt_ms: f64Running average round-trip time across all successful pings (milliseconds).
Implementations§
Source§impl PeerConnectionInfo
impl PeerConnectionInfo
Sourcepub fn uptime_secs(&self, now_secs: u64) -> u64
pub fn uptime_secs(&self, now_secs: u64) -> u64
Seconds the peer has been connected, measured from now_secs.
Returns 0 if the peer is not currently connected.
Sourcepub fn reliability(&self) -> f64
pub fn reliability(&self) -> f64
Fraction of pings that succeeded: 1.0 - (failures / total.max(1)).
Trait Implementations§
Source§impl Clone for PeerConnectionInfo
impl Clone for PeerConnectionInfo
Source§fn clone(&self) -> PeerConnectionInfo
fn clone(&self) -> PeerConnectionInfo
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PeerConnectionInfo
impl RefUnwindSafe for PeerConnectionInfo
impl Send for PeerConnectionInfo
impl Sync for PeerConnectionInfo
impl Unpin for PeerConnectionInfo
impl UnsafeUnpin for PeerConnectionInfo
impl UnwindSafe for PeerConnectionInfo
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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