mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 07:17:27 +00:00
chore: extract the ship into multiple files (#172)
* chore: extract the ship into multiple files * fix: actual the ship reference link * fix: revert last commit and replace in ts
This commit is contained in:
parent
99b0269ec2
commit
bdcf64facf
3 changed files with 36 additions and 29 deletions
8
crates/lib/src/games/theship/mod.rs
Normal file
8
crates/lib/src/games/theship/mod.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/// The implementation.
|
||||
/// Reference: [server queries](https://developer.valvesoftware.com/wiki/Server_queries)
|
||||
pub mod protocol;
|
||||
/// All types used by the implementation.
|
||||
pub mod types;
|
||||
|
||||
pub use protocol::*;
|
||||
pub use types::*;
|
||||
23
crates/lib/src/games/theship/protocol.rs
Normal file
23
crates/lib/src/games/theship/protocol.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use crate::games::theship::types::Response;
|
||||
use crate::protocols::types::TimeoutSettings;
|
||||
use crate::protocols::valve;
|
||||
use crate::protocols::valve::Engine;
|
||||
use crate::GDResult;
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
|
||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> { query_with_timeout(address, port, None) }
|
||||
|
||||
pub fn query_with_timeout(
|
||||
address: &IpAddr,
|
||||
port: Option<u16>,
|
||||
timeout_settings: Option<TimeoutSettings>,
|
||||
) -> GDResult<Response> {
|
||||
let valve_response = valve::query(
|
||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
||||
Engine::new(2400),
|
||||
None,
|
||||
timeout_settings,
|
||||
)?;
|
||||
|
||||
Response::new_from_valve_response(valve_response)
|
||||
}
|
||||
|
|
@ -1,17 +1,10 @@
|
|||
use crate::{
|
||||
protocols::{
|
||||
types::{CommonPlayer, CommonResponse, GenericPlayer, TimeoutSettings},
|
||||
valve::{self, get_optional_extracted_data, Server, ServerPlayer},
|
||||
GenericResponse,
|
||||
},
|
||||
GDErrorKind::PacketBad,
|
||||
GDResult,
|
||||
};
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
|
||||
use crate::protocols::types::{CommonPlayer, CommonResponse, GenericPlayer};
|
||||
use crate::protocols::valve::{get_optional_extracted_data, Server, ServerPlayer};
|
||||
use crate::protocols::{valve, GenericResponse};
|
||||
use crate::GDErrorKind::PacketBad;
|
||||
use crate::GDResult;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::protocols::valve::Engine;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
@ -127,20 +120,3 @@ impl Response {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> { query_with_timeout(address, port, None) }
|
||||
|
||||
pub fn query_with_timeout(
|
||||
address: &IpAddr,
|
||||
port: Option<u16>,
|
||||
timeout_settings: Option<TimeoutSettings>,
|
||||
) -> GDResult<Response> {
|
||||
let valve_response = valve::query(
|
||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
||||
Engine::new(2400),
|
||||
None,
|
||||
timeout_settings,
|
||||
)?;
|
||||
|
||||
Response::new_from_valve_response(valve_response)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue