1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/// Statistics about the quality of the network connection to a remote peer.
///
/// Obtained via [`P2PSession::network_stats()`] or [`SpectatorSession::network_stats()`].
///
/// # Availability
///
/// Stats are computed over a rolling 1-second window. Until at least one second has elapsed
/// since the session entered the [`Running`] state, those methods return
/// [`GgrsError::NotEnoughData`] rather than a `NetworkStats` value. Poll in your game loop
/// after synchronization and discard the error until data is available:
///
/// ```ignore
/// match session.network_stats(player_handle) {
/// Ok(stats) => { /* use stats */ }
/// Err(GgrsError::NotEnoughData) => { /* still warming up — ignore */ }
/// Err(e) => return Err(e),
/// }
/// ```
///
/// [`P2PSession::network_stats()`]: crate::P2PSession::network_stats
/// [`SpectatorSession::network_stats()`]: crate::SpectatorSession::network_stats
/// [`Running`]: crate::SessionState::Running
/// [`GgrsError::NotEnoughData`]: crate::GgrsError::NotEnoughData