mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
[Crate] Enforce formatting in CI (#46)
* [CI] Check formatting * Format all files
This commit is contained in:
parent
a6279177bb
commit
b95b2abe0f
76 changed files with 251 additions and 170 deletions
|
|
@ -1,12 +1,12 @@
|
|||
use std::net::SocketAddr;
|
||||
use std::slice::Iter;
|
||||
use crate::{GDError, GDResult};
|
||||
use crate::protocols::quake::client::{client_query, remove_wrapping_quotes, QuakeClient};
|
||||
use crate::protocols::quake::one::QuakeOne;
|
||||
use crate::protocols::quake::Response;
|
||||
use crate::protocols::quake::client::{QuakeClient, client_query, remove_wrapping_quotes};
|
||||
use crate::protocols::types::TimeoutSettings;
|
||||
use crate::{GDError, GDResult};
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::net::SocketAddr;
|
||||
use std::slice::Iter;
|
||||
|
||||
/// Quake 2 player data.
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
|
@ -14,35 +14,31 @@ use serde::{Deserialize, Serialize};
|
|||
pub struct Player {
|
||||
pub frags: i16,
|
||||
pub ping: u16,
|
||||
pub name: String
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
pub(crate) struct QuakeTwo;
|
||||
impl QuakeClient for QuakeTwo {
|
||||
type Player = Player;
|
||||
|
||||
fn get_send_header<'a>() -> &'a str {
|
||||
QuakeOne::get_send_header()
|
||||
}
|
||||
fn get_send_header<'a>() -> &'a str { QuakeOne::get_send_header() }
|
||||
|
||||
fn get_response_header<'a>() -> &'a str {
|
||||
"print\n"
|
||||
}
|
||||
fn get_response_header<'a>() -> &'a str { "print\n" }
|
||||
|
||||
fn parse_player_string(mut data: Iter<&str>) -> GDResult<Self::Player> {
|
||||
Ok(Player {
|
||||
frags: match data.next() {
|
||||
None => Err(GDError::PacketBad)?,
|
||||
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?
|
||||
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?,
|
||||
},
|
||||
ping: match data.next() {
|
||||
None => Err(GDError::PacketBad)?,
|
||||
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?
|
||||
Some(v) => v.parse().map_err(|_| GDError::PacketBad)?,
|
||||
},
|
||||
name: match data.next() {
|
||||
None => Err(GDError::PacketBad)?,
|
||||
Some(v) => remove_wrapping_quotes(v).to_string()
|
||||
}
|
||||
Some(v) => remove_wrapping_quotes(v).to_string(),
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue