mirror of
https://github.com/Tribufu/rust-gamedig
synced 2026-08-10 15:41:05 +00:00
Reverter errors from taking a &'static str to String
This commit is contained in:
parent
dc0926bab7
commit
7b44c5f7eb
10 changed files with 59 additions and 59 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue