Reverter errors from taking a &'static str to String

This commit is contained in:
CosminPerRam 2022-11-25 18:42:10 +02:00
parent dc0926bab7
commit 7b44c5f7eb
10 changed files with 59 additions and 59 deletions

View file

@ -52,13 +52,13 @@ impl LegacyV1_6 {
error_by_expected_size(5, split.len())?;
let version_protocol = split[0].parse()
.map_err(|_| GDError::PacketBad("Failed to parse to expected int."))?;
.map_err(|_| GDError::PacketBad("Failed to parse to expected int.".to_string()))?;
let version_name = split[1].to_string();
let description = split[2].to_string();
let max_players = split[3].parse()
.map_err(|_| GDError::PacketBad("Failed to parse to expected int."))?;
.map_err(|_| GDError::PacketBad("Failed to parse to expected int.".to_string()))?;
let online_players = split[4].parse()
.map_err(|_| GDError::PacketBad("Failed to parse to expected int."))?;
.map_err(|_| GDError::PacketBad("Failed to parse to expected int.".to_string()))?;
Ok(Response {
version_name,
@ -81,14 +81,14 @@ impl LegacyV1_6 {
let mut pos = 0;
if get_u8(&buf, &mut pos)? != 0xFF {
return Err(GDError::ProtocolFormat("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.".to_string()));
}
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::ProtocolFormat("Expected certain bytes at the beginning of the packet."));
return Err(GDError::ProtocolFormat("Expected certain bytes at the beginning of the packet.".to_string()));
}
LegacyV1_6::get_response(&buf, &mut pos)