Skip to content

Commit

Permalink
tidy: Move TimeoutSettings out of protocol types
Browse files Browse the repository at this point in the history
  • Loading branch information
Douile committed Nov 22, 2023
1 parent 7416d54 commit 7ee1071
Show file tree
Hide file tree
Showing 26 changed files with 209 additions and 187 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Game:
Protocols:
- Valve: Removed `SteamApp` due to it not being really useful at all, replaced all instances with `Engine`.

Crate:
- TimeoutSettings should now be imported from the root of the crate
- `use gamedig::TimeoutSettings`

# 0.4.1 - 13/10/2023
### Changes:
Game:
Expand Down
5 changes: 3 additions & 2 deletions crates/lib/examples/generic.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use gamedig::{
protocols::types::{CommonResponse, ExtraRequestSettings, TimeoutSettings},
protocols::types::{CommonResponse, ExtraRequestSettings},
query_with_timeout_and_extra_settings,
GDResult,
Game,
TimeoutSettings,
GAMES,
};

Expand Down Expand Up @@ -77,7 +78,7 @@ fn main() {

#[cfg(test)]
mod test {
use gamedig::{protocols::types::TimeoutSettings, GAMES};
use gamedig::{TimeoutSettings, GAMES};
use std::{
net::{IpAddr, Ipv4Addr},
time::Duration,
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/examples/valve_protocol_query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gamedig::protocols::types::TimeoutSettings;
use gamedig::protocols::valve;
use gamedig::protocols::valve::{Engine, GatheringSettings};
use gamedig::TimeoutSettings;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::time::Duration;

Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/games/ffow.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::buffer::{Buffer, Utf8Decoder};
use crate::protocols::types::{CommonResponse, TimeoutSettings};
use crate::protocols::types::CommonResponse;
use crate::protocols::valve::{Engine, Environment, Server, ValveProtocol};
use crate::protocols::GenericResponse;
use crate::GDResult;
use crate::{GDResult, TimeoutSettings};
use byteorder::LittleEndian;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/games/jc2m.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::buffer::{Buffer, Utf8Decoder};
use crate::protocols::gamespy::common::has_password;
use crate::protocols::gamespy::three::{data_to_map, GameSpy3};
use crate::protocols::types::{CommonPlayer, CommonResponse, GenericPlayer, TimeoutSettings};
use crate::protocols::types::{CommonPlayer, CommonResponse, GenericPlayer};
use crate::protocols::GenericResponse;
use crate::GDErrorKind::{PacketBad, TypeParse};
use crate::{GDErrorKind, GDResult};
use crate::{GDErrorKind, GDResult, TimeoutSettings};
use byteorder::BigEndian;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/games/minecraft/protocol/bedrock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
use crate::{
buffer::{Buffer, Utf8Decoder},
games::minecraft::{BedrockResponse, GameMode, Server},
protocols::types::TimeoutSettings,
socket::{Socket, UdpSocket},
utils::{error_by_expected_size, retry_on_timeout},
GDErrorKind::{PacketBad, TypeParse},
GDResult,
TimeoutSettings,
};

use std::net::SocketAddr;
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/games/minecraft/protocol/java.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{
buffer::Buffer,
games::minecraft::{as_string, as_varint, get_string, get_varint, JavaResponse, Player, RequestSettings, Server},
protocols::types::TimeoutSettings,
socket::{Socket, TcpSocket},
utils::retry_on_timeout,
GDErrorKind::{JsonParse, PacketBad},
GDResult,
TimeoutSettings,
};

use byteorder::LittleEndian;
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/games/minecraft/protocol/legacy_v1_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use crate::minecraft::protocol::legacy_v1_6::LegacyV1_6;
use crate::{
buffer::{Buffer, Utf16Decoder},
games::minecraft::{JavaResponse, LegacyGroup, Server},
protocols::types::TimeoutSettings,
socket::{Socket, TcpSocket},
utils::{error_by_expected_size, retry_on_timeout},
GDErrorKind::{PacketBad, ProtocolFormat},
GDResult,
TimeoutSettings,
};
use std::net::SocketAddr;

Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/games/minecraft/protocol/legacy_v1_6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use byteorder::BigEndian;
use crate::{
buffer::{Buffer, Utf16Decoder},
games::minecraft::{JavaResponse, LegacyGroup, Server},
protocols::types::TimeoutSettings,
socket::{Socket, TcpSocket},
utils::{error_by_expected_size, retry_on_timeout},
GDErrorKind::{PacketBad, ProtocolFormat},
GDResult,
TimeoutSettings,
};
use std::net::SocketAddr;

Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/games/minecraft/protocol/legacy_vb1_8.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{
buffer::{Buffer, Utf16Decoder},
games::minecraft::{JavaResponse, LegacyGroup, Server},
protocols::types::TimeoutSettings,
socket::{Socket, TcpSocket},
utils::{error_by_expected_size, retry_on_timeout},
GDErrorKind::{PacketBad, ProtocolFormat},
GDResult,
TimeoutSettings,
};

use std::net::SocketAddr;
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/games/minecraft/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use crate::{
JavaResponse,
LegacyGroup,
},
protocols::types::TimeoutSettings,
GDErrorKind::AutoQuery,
GDResult,
TimeoutSettings,
};
use std::net::SocketAddr;

Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/games/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pub mod theship;

use crate::protocols::gamespy::GameSpyVersion;
use crate::protocols::quake::QuakeVersion;
use crate::protocols::types::{CommonResponse, ExtraRequestSettings, ProprietaryProtocol, TimeoutSettings};
use crate::protocols::types::{CommonResponse, ExtraRequestSettings, ProprietaryProtocol};
use crate::protocols::{self, Protocol};
use crate::GDResult;
use crate::{GDResult, TimeoutSettings};
use std::net::{IpAddr, SocketAddr};

/// Definition of a game
Expand Down
3 changes: 2 additions & 1 deletion crates/lib/src/games/theship.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::{
protocols::{
types::{CommonPlayer, CommonResponse, GenericPlayer, TimeoutSettings},
types::{CommonPlayer, CommonResponse, GenericPlayer},
valve::{self, get_optional_extracted_data, Server, ServerPlayer},
GenericResponse,
},
GDErrorKind::PacketBad,
GDResult,
TimeoutSettings,
};
use std::net::{IpAddr, SocketAddr};

Expand Down
3 changes: 3 additions & 0 deletions crates/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub mod games;
pub mod protocols;
#[cfg(feature = "services")]
pub mod services;
pub mod types;

mod buffer;
mod socket;
Expand All @@ -50,3 +51,5 @@ pub use errors::*;
pub use games::*;
#[cfg(feature = "services")]
pub use services::*;

pub use types::*;
6 changes: 2 additions & 4 deletions crates/lib/src/protocols/gamespy/protocols/one/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ use crate::GDErrorKind::TypeParse;
use crate::utils::retry_on_timeout;
use crate::{
buffer::Buffer,
protocols::{
gamespy::one::{Player, Response},
types::TimeoutSettings,
},
protocols::gamespy::one::{Player, Response},
socket::{Socket, UdpSocket},
GDErrorKind,
GDResult,
TimeoutSettings,
};
use std::collections::HashMap;
use std::net::SocketAddr;
Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/protocols/gamespy/protocols/three/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use byteorder::{BigEndian, LittleEndian};
use crate::buffer::{Buffer, Utf8Decoder};
use crate::protocols::gamespy::common::has_password;
use crate::protocols::gamespy::three::{Player, Response, Team};
use crate::protocols::types::TimeoutSettings;
use crate::socket::{Socket, UdpSocket};
use crate::utils::retry_on_timeout;
use crate::GDErrorKind::{PacketBad, TypeParse};
use crate::{GDErrorKind, GDResult};
use crate::{GDErrorKind, GDResult, TimeoutSettings};

use std::collections::HashMap;
use std::net::SocketAddr;

Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/protocols/gamespy/protocols/two/protocol.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::buffer::{Buffer, Utf8Decoder};
use crate::protocols::gamespy::two::{Player, Response, Team};
use crate::protocols::types::TimeoutSettings;
use crate::socket::{Socket, UdpSocket};
use crate::utils::retry_on_timeout;
use crate::GDErrorKind::{PacketBad, TypeParse};
use crate::{GDErrorKind, GDResult};
use crate::{GDErrorKind, GDResult, TimeoutSettings};

use byteorder::BigEndian;
use std::collections::HashMap;
use std::net::SocketAddr;
Expand Down
3 changes: 1 addition & 2 deletions crates/lib/src/protocols/quake/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ use byteorder::LittleEndian;

use crate::buffer::{Buffer, Utf8Decoder};
use crate::protocols::quake::types::Response;
use crate::protocols::types::TimeoutSettings;
use crate::socket::{Socket, UdpSocket};
use crate::utils::retry_on_timeout;
use crate::GDErrorKind::{PacketBad, TypeParse};
use crate::{GDErrorKind, GDResult};
use crate::{GDErrorKind, GDResult, TimeoutSettings};
use std::collections::HashMap;
use std::net::SocketAddr;
use std::slice::Iter;
Expand Down
5 changes: 3 additions & 2 deletions crates/lib/src/protocols/quake/one.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::protocols::quake::client::{client_query, remove_wrapping_quotes, QuakeClient};
use crate::protocols::quake::Response;
use crate::protocols::types::{CommonPlayer, GenericPlayer, TimeoutSettings};
use crate::protocols::types::{CommonPlayer, GenericPlayer};
use crate::GDErrorKind::TypeParse;
use crate::{GDErrorKind, GDResult};
use crate::{GDErrorKind, GDResult, TimeoutSettings};

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::net::SocketAddr;
Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/protocols/quake/three.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::protocols::quake::client::{client_query, QuakeClient};
use crate::protocols::quake::two::QuakeTwo;
use crate::protocols::quake::Response;
use crate::protocols::types::TimeoutSettings;
use crate::GDResult;
use crate::{GDResult, TimeoutSettings};

use std::net::SocketAddr;
use std::slice::Iter;

Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/protocols/quake/two.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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::types::{CommonPlayer, GenericPlayer, TimeoutSettings};
use crate::protocols::types::{CommonPlayer, GenericPlayer};
use crate::GDErrorKind::TypeParse;
use crate::{GDErrorKind, GDResult};
use crate::{GDErrorKind, GDResult, TimeoutSettings};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::net::SocketAddr;
Expand Down
Loading

0 comments on commit 7ee1071

Please sign in to comment.