#[derive(Copy, Clone, Eq, PartialEq, Debug, Display, Error)]
#[display(doc_comments)]
#[repr(u8)]
#[non_exhaustive]
pub enum ServerError {
GeneralFailure = 1,
NotAllowed = 2,
NetworkUnreachable = 3,
HostUnreachable = 4,
ConnectionRefused = 5,
TtlExpired = 6,
CommandNotSupported = 7,
AddressNotSupported = 8,
HsDescNotFound = 0xF0,
HsDescInvalid = 0xF1,
HsIntroFailed = 0xF2,
HsRendFailed = 0xF3,
HsMissingClientAuth = 0xF4,
HsWrongClientAuth = 0xF5,
HsBadAddress = 0xF6,
HsIntroTimeout = 0xF7,
Unknown = 0xFF,
}
impl From<u8> for ServerError {
fn from(value: u8) -> Self {
const ALL: [ServerError; 16] = [
ServerError::GeneralFailure,
ServerError::NotAllowed,
ServerError::NetworkUnreachable,
ServerError::HostUnreachable,
ServerError::ConnectionRefused,
ServerError::TtlExpired,
ServerError::CommandNotSupported,
ServerError::AddressNotSupported,
ServerError::HsDescNotFound,
ServerError::HsDescInvalid,
ServerError::HsIntroFailed,
ServerError::HsRendFailed,
ServerError::HsMissingClientAuth,
ServerError::HsWrongClientAuth,
ServerError::HsBadAddress,
ServerError::HsIntroTimeout,
];
for ty in ALL {
if ty as u8 == value {
return ty;
}
}
ServerError::Unknown
}
}