1use std::fmt;
2
3pub type NetcodeResult<T> = std::result::Result<T, NetcodeError>;
5
6#[derive(Debug, Clone, PartialEq, Eq)]
8#[non_exhaustive]
9pub enum NetcodeError {
10 InvalidConfig(&'static str),
12 InvalidSample(&'static str),
14 InvalidInput(&'static str),
16 InputHistoryFull,
18 SequenceExhausted,
20 InvalidAcknowledgement,
22 PredictionHistoryFull,
24 ReplayLimitExceeded,
26 InterpolationBufferEmpty,
28 PredictedEntityLimit,
30}
31
32impl fmt::Display for NetcodeError {
33 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
34 match self {
35 Self::InvalidConfig(message) => write!(formatter, "invalid netcode config: {message}"),
36 Self::InvalidSample(message) => write!(formatter, "invalid Tick sample: {message}"),
37 Self::InvalidInput(message) => write!(formatter, "invalid input: {message}"),
38 Self::InputHistoryFull => formatter.write_str("unacknowledged input history is full"),
39 Self::SequenceExhausted => formatter.write_str("input sequence is exhausted"),
40 Self::InvalidAcknowledgement => {
41 formatter.write_str("peer acknowledged an input sequence that was never issued")
42 }
43 Self::PredictionHistoryFull => {
44 formatter.write_str("unconfirmed prediction history is full")
45 }
46 Self::ReplayLimitExceeded => formatter.write_str("prediction replay limit exceeded"),
47 Self::InterpolationBufferEmpty => {
48 formatter.write_str("remote interpolation buffer is empty")
49 }
50 Self::PredictedEntityLimit => {
51 formatter.write_str("pending predicted entity limit exceeded")
52 }
53 }
54 }
55}
56
57impl std::error::Error for NetcodeError {}