mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 15:27:28 +00:00
[Crate] Make clippy happy (#23)
* fix: clippy::type_complexity * fix: clippy::needless_doctest_main * fix: clippy::read_zero_byte_vec * fix: clippy::useless_conversion * fix: clippy::slow_vector_initialization
This commit is contained in:
parent
7f73eb582d
commit
bd2e373d66
4 changed files with 31 additions and 21 deletions
|
|
@ -125,11 +125,13 @@ impl Bufferer {
|
|||
return Err(PacketUnderflow);
|
||||
}
|
||||
|
||||
let paired_buf: Vec<u16> = sub_buf.chunks_exact(2)
|
||||
.into_iter().map(|pair| match self.endianess {
|
||||
Endianess::Little => LittleEndian::read_u16(pair),
|
||||
Endianess::Big => BigEndian::read_u16(pair)
|
||||
}).collect();
|
||||
let paired_buf: Vec<u16> = sub_buf
|
||||
.chunks_exact(2)
|
||||
.map(|pair| match self.endianess {
|
||||
Endianess::Little => LittleEndian::read_u16(pair),
|
||||
Endianess::Big => BigEndian::read_u16(pair),
|
||||
})
|
||||
.collect();
|
||||
|
||||
let value = String::from_utf16(&paired_buf).map_err(|_| PacketBad)?;
|
||||
|
||||
|
|
|
|||
23
src/lib.rs
23
src/lib.rs
|
|
@ -1,18 +1,15 @@
|
|||
|
||||
//! Game Server Query Library.
|
||||
//!
|
||||
//! # Usage example:
|
||||
//!
|
||||
//! ```no_run
|
||||
//!use gamedig::games::tf2;
|
||||
//! ```
|
||||
//! use gamedig::games::tf2;
|
||||
//!
|
||||
//!fn main() {
|
||||
//! let response = tf2::query("127.0.0.1", None); // None is the default port (which is 27015), could also be Some(27015)
|
||||
//! match response { // Result type, must check what it is...
|
||||
//! Err(error) => println!("Couldn't query, error: {}", error),
|
||||
//! Ok(r) => println!("{:#?}", r)
|
||||
//! }
|
||||
//!}
|
||||
//! let response = tf2::query("127.0.0.1", None); // None is the default port (which is 27015), could also be Some(27015)
|
||||
//! match response { // Result type, must check what it is...
|
||||
//! Err(error) => println!("Couldn't query, error: {}", error),
|
||||
//! Ok(r) => println!("{:#?}", r)
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! # Crate features:
|
||||
|
|
@ -21,13 +18,13 @@
|
|||
//! `no_games` - disables the included games support.
|
||||
|
||||
pub mod errors;
|
||||
pub mod protocols;
|
||||
#[cfg(not(feature = "no_games"))]
|
||||
pub mod games;
|
||||
pub mod protocols;
|
||||
|
||||
mod utils;
|
||||
mod socket;
|
||||
mod bufferer;
|
||||
mod socket;
|
||||
mod utils;
|
||||
|
||||
pub use errors::*;
|
||||
#[cfg(not(feature = "no_games"))]
|
||||
|
|
|
|||
|
|
@ -121,7 +121,8 @@ impl SplitPacket {
|
|||
|
||||
let decompressed_size = self.decompressed_size.unwrap() as usize;
|
||||
|
||||
let mut decompressed_payload = Vec::with_capacity(decompressed_size);
|
||||
let mut decompressed_payload = vec![0; decompressed_size];
|
||||
|
||||
decoder.read(&mut decompressed_payload).map_err(|_| Decompress)?;
|
||||
|
||||
if decompressed_payload.len() != decompressed_size
|
||||
|
|
|
|||
|
|
@ -116,10 +116,20 @@ pub struct ModData {
|
|||
pub has_own_dll: bool
|
||||
}
|
||||
|
||||
pub(crate) fn get_optional_extracted_data(data: Option<ExtraData>) -> (Option<u16>, Option<u64>, Option<u16>, Option<String>, Option<String>) {
|
||||
pub(crate) type ExtractedData = (
|
||||
Option<u16>,
|
||||
Option<u64>,
|
||||
Option<u16>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
);
|
||||
|
||||
pub(crate) fn get_optional_extracted_data(
|
||||
data: Option<ExtraData>,
|
||||
) -> ExtractedData {
|
||||
match data {
|
||||
None => (None, None, None, None, None),
|
||||
Some(ed) => (ed.port, ed.steam_id, ed.tv_port, ed.tv_name, ed.keywords)
|
||||
Some(ed) => (ed.port, ed.steam_id, ed.tv_port, ed.tv_name, ed.keywords),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue