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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use std::error::Error;
use std::fmt;
use std::fmt::Display;
use crate::Frame;
#[derive(Debug, Clone, PartialEq, Hash)]
pub enum GGRSError {
InvalidHandle,
PredictionThreshold,
InvalidRequest { info: String },
MismatchedChecksum { frame: Frame },
SocketCreationFailed,
NotSynchronized,
PlayerDisconnected,
SpectatorTooFarBehind,
}
impl Display for GGRSError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
GGRSError::InvalidHandle => {
write!(f, "The player handle you provided is invalid.")
}
GGRSError::PredictionThreshold => {
write!(
f,
"Prediction threshold is reached, cannot proceed without catching up."
)
}
GGRSError::InvalidRequest { info } => {
write!(f, "Invalid Request: {}", info)
}
GGRSError::NotSynchronized => {
write!(
f,
"The session is not yet synchronized with all remote sessions."
)
}
GGRSError::MismatchedChecksum { frame } => {
write!(
f,
"Detected checksum mismatch during rollback on frame {}.",
frame
)
}
GGRSError::SocketCreationFailed => {
write!(f, "UPD Socket creation failed.")
}
GGRSError::PlayerDisconnected => {
write!(
f,
"The player you are trying to disconnect is already disconnected."
)
}
GGRSError::SpectatorTooFarBehind => {
write!(
f,
"The spectator got so far behind the host that catching up is impossible."
)
}
}
}
}
impl Error for GGRSError {}