use thiserror::Error;
#[derive(Error, Debug)]
pub enum CreatePacketError {
#[error("Input payload should not contain 0x00")]
InputPayloadContainsZero,
#[error("Input payload oversize")]
InputPayloadOversize,
#[error("Missing field {0} when creating packet")]
MissingField(&'static str),
}
#[derive(Error, Debug)]
pub enum BPacketConverterError {
#[error("Invalid packet: {0}")]
InvalidPacket(String),
#[error("Segmenting Error: {0}")]
SegmentingError(String),
}
#[derive(Error, Debug)]
pub enum RconConnectionError {
#[error("TCPConnection Timeout")]
TCPConnectionTimeoutError,
#[error("TCPConnection Error")]
TCPConnectionError(#[source] std::io::Error),
#[error("Missing field {0} when creating TCP Stream")]
MissingField(&'static str),
#[error("Stream reading error")]
StreamReadingError(#[source] std::io::Error),
#[error("Stream writing error")]
StreamWritingError(#[source] std::io::Error),
#[error("Stream closing error")]
StreamClosingError(#[source] std::io::Error),
}
#[derive(Error, Debug)]
pub enum RconError {
#[error("Missing field {0} when creating an Rcon connection")]
MissingField(&'static str),
#[error("Authentication Failed: Incorrect Password")]
IncorrectPasswordError,
#[error("Rcon connection error")]
RconConnectionError(#[from] RconConnectionError),
#[error("Failed to create packet")]
PacketCreationError(#[from] CreatePacketError),
#[error("Failed to parse received packet")]
PacketConversionError(#[from] BPacketConverterError),
#[error("Feedback information is None")]
FeedbackIsNone,
#[error("Mismatched Response Packet ID")]
MismatchedResponsePacketID,
#[error("Port number is out of range")]
PortOutOfRangeError,
#[error("Invalid Command")]
InvalidCommandError,
#[error("UnknownParserError for {0}")]
UnknownParserError(String),
#[error("InvalidCoordinate: {0}")]
InvalidCoordinate(String),
#[error("InvalidArgument: {0}")]
InvalidCommandArgument(String),
}