Renamed ProtocolRule to ProtocolFormat

This commit is contained in:
CosminPerRam 2022-11-24 23:41:23 +02:00
parent 304b8340d2
commit dc0926bab7
4 changed files with 6 additions and 6 deletions

View file

@ -39,7 +39,7 @@ pub enum GDError {
/// Couldn't automatically query.
AutoQuery(&'static str),
/// A protocol-defined expected format was not met.
ProtocolRule(&'static str),
ProtocolFormat(&'static str),
}
impl fmt::Display for GDError {
@ -59,7 +59,7 @@ impl fmt::Display for GDError {
GDError::SocketConnect(details) => write!(f, "Socket connect: {details}"),
GDError::JsonParse(details) => write!(f, "Json parse: {details}"),
GDError::AutoQuery(details) => write!(f, "Auto query: {details}"),
GDError::ProtocolRule(details) => write!(f, "Protocol rule: {details}"),
GDError::ProtocolFormat(details) => write!(f, "Protocol rule: {details}"),
}
}
}

View file

@ -31,7 +31,7 @@ impl LegacyBV1_8 {
let mut pos = 0;
if get_u8(&buf, &mut pos)? != 0xFF {
return Err(GDError::ProtocolRule("Expected 0xFF at the begin of the packet."));
return Err(GDError::ProtocolFormat("Expected 0xFF at the begin of the packet."));
}
let length = get_u16_be(&buf, &mut pos)? * 2;

View file

@ -32,7 +32,7 @@ impl LegacyV1_4 {
let mut pos = 0;
if get_u8(&buf, &mut pos)? != 0xFF {
return Err(GDError::ProtocolRule("Expected 0xFF at the begin of the packet."));
return Err(GDError::ProtocolFormat("Expected 0xFF at the begin of the packet."));
}
let length = get_u16_be(&buf, &mut pos)? * 2;

View file

@ -81,14 +81,14 @@ impl LegacyV1_6 {
let mut pos = 0;
if get_u8(&buf, &mut pos)? != 0xFF {
return Err(GDError::ProtocolRule("Expected a certain byte (0xFF) at the begin of the packet."));
return Err(GDError::ProtocolFormat("Expected a certain byte (0xFF) at the begin of the packet."));
}
let length = get_u16_be(&buf, &mut pos)? * 2;
error_by_expected_size((length + 3) as usize, buf.len())?;
if !LegacyV1_6::is_protocol(&buf, &mut pos)? {
return Err(GDError::ProtocolRule("Expected certain bytes at the beginning of the packet."));
return Err(GDError::ProtocolFormat("Expected certain bytes at the beginning of the packet."));
}
LegacyV1_6::get_response(&buf, &mut pos)