mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
[Protocol] Some cargo clippy improvements for GS one and three
This commit is contained in:
parent
4122d34cfa
commit
c5fd58f794
2 changed files with 6 additions and 6 deletions
|
|
@ -219,7 +219,7 @@ pub fn query(address: &str, port: u16, timeout_settings: Option<TimeoutSettings>
|
||||||
players,
|
players,
|
||||||
tournament: server_vars
|
tournament: server_vars
|
||||||
.remove("tournament")
|
.remove("tournament")
|
||||||
.unwrap_or("true".to_string())
|
.unwrap_or_else(|| "true".to_string())
|
||||||
.to_lowercase()
|
.to_lowercase()
|
||||||
.parse()
|
.parse()
|
||||||
.map_err(|_| GDError::TypeParse)?,
|
.map_err(|_| GDError::TypeParse)?,
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ struct RequestPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RequestPacket {
|
impl RequestPacket {
|
||||||
fn to_bytes(self) -> Vec<u8> {
|
fn to_bytes(&self) -> Vec<u8> {
|
||||||
let mut packet: Vec<u8> = Vec::with_capacity(7);
|
let mut packet: Vec<u8> = Vec::with_capacity(7);
|
||||||
packet.extend_from_slice(&self.header.to_be_bytes());
|
packet.extend_from_slice(&self.header.to_be_bytes());
|
||||||
packet.push(self.kind);
|
packet.push(self.kind);
|
||||||
|
|
@ -144,10 +144,10 @@ fn get_server_packets(address: &str, port: u16, timeout_settings: Option<Timeout
|
||||||
Ok(values)
|
Ok(values)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn data_to_map(packet: &Vec<u8>) -> GDResult<(HashMap<String, String>, Vec<u8>)> {
|
fn data_to_map(packet: &[u8]) -> GDResult<(HashMap<String, String>, Vec<u8>)> {
|
||||||
let mut vars = HashMap::new();
|
let mut vars = HashMap::new();
|
||||||
|
|
||||||
let mut buf = Bufferer::new_with_data(Endianess::Big, &packet);
|
let mut buf = Bufferer::new_with_data(Endianess::Big, packet);
|
||||||
while buf.remaining_length() > 0 {
|
while buf.remaining_length() > 0 {
|
||||||
let key = buf.get_string_utf8()?;
|
let key = buf.get_string_utf8()?;
|
||||||
if key.is_empty() {
|
if key.is_empty() {
|
||||||
|
|
@ -201,7 +201,7 @@ fn parse_players_and_teams(packets: Vec<Vec<u8>>) -> GDResult<(Vec<Player>, Vec<
|
||||||
}
|
}
|
||||||
|
|
||||||
let field_split: Vec<&str> = field.split('_').collect();
|
let field_split: Vec<&str> = field.split('_').collect();
|
||||||
let field_name = field_split.get(0).ok_or(GDError::PacketBad)?;
|
let field_name = field_split.first().ok_or(GDError::PacketBad)?;
|
||||||
if !["player", "score", "ping", "team", "deaths", "pid", "skill"].contains(field_name) {
|
if !["player", "score", "ping", "team", "deaths", "pid", "skill"].contains(field_name) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -342,7 +342,7 @@ pub fn query(address: &str, port: u16, timeout_settings: Option<TimeoutSettings>
|
||||||
teams,
|
teams,
|
||||||
tournament: server_vars
|
tournament: server_vars
|
||||||
.remove("tournament")
|
.remove("tournament")
|
||||||
.unwrap_or("true".to_string())
|
.unwrap_or_else(|| "true".to_string())
|
||||||
.to_lowercase()
|
.to_lowercase()
|
||||||
.parse()
|
.parse()
|
||||||
.map_err(|_| GDError::TypeParse)?,
|
.map_err(|_| GDError::TypeParse)?,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue