pub struct ConnectionStats {
pub bytes_sent: u64,
pub bytes_received: u64,
pub rtt: Duration,
pub connected_duration: Duration,
pub streams_opened: u64,
pub packets_lost: u64,
}Expand description
Statistics for a connection.
Updated in real-time as the connection handles data. Use for:
- Monitoring connection health
- Detecting congestion (high RTT, packet loss)
- Debugging performance issues
§Typical Values
| Metric | Good | Concerning | Critical |
|---|---|---|---|
| RTT | <50ms | 50-200ms | >500ms |
| Packet loss | <0.1% | 0.1-1% | >5% |
§Example
ⓘ
let stats = conn.stats();
if stats.rtt > Duration::from_millis(200) {
log::warn!("High latency: {:?}", stats.rtt);
}
if stats.packets_lost > stats.bytes_sent / 100 {
log::warn!("Significant packet loss detected");
}Fields§
§bytes_sent: u64Total bytes sent on this connection (including retransmits).
bytes_received: u64Total bytes received on this connection.
rtt: DurationCurrent smoothed round-trip time estimate. Calculated using QUIC’s RTT estimation algorithm.
connected_duration: DurationHow long this connection has been established.
streams_opened: u64Total number of streams opened (bidirectional + unidirectional).
packets_lost: u64Estimated packets lost during transmission. High values indicate congestion or poor network conditions.
Trait Implementations§
Source§impl Clone for ConnectionStats
impl Clone for ConnectionStats
Source§fn clone(&self) -> ConnectionStats
fn clone(&self) -> ConnectionStats
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConnectionStats
impl Debug for ConnectionStats
Source§impl Default for ConnectionStats
impl Default for ConnectionStats
Source§fn default() -> ConnectionStats
fn default() -> ConnectionStats
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ConnectionStats
impl RefUnwindSafe for ConnectionStats
impl Send for ConnectionStats
impl Sync for ConnectionStats
impl Unpin for ConnectionStats
impl UnwindSafe for ConnectionStats
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