use insim_core::binrw::{self, binrw};
use crate::identifiers::RequestId;
#[binrw]
#[derive(Debug, Clone, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[repr(u8)]
#[brw(repr(u8))]
pub enum RelayErrorKind {
#[default]
None = 0,
InvalidPacketLength = 1,
InvalidPacketType = 2,
InvalidHostname = 3,
BadAdminPassword = 4,
BadSpectatorPassword = 5,
MissingSpectatorPassword = 6,
}
#[binrw]
#[derive(Debug, Clone, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
pub struct Error {
pub reqi: RequestId,
pub err: RelayErrorKind,
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Encountered a Relay Error: {:?}", self.err)
}
}
impl std::error::Error for Error {}