Update docs.

This commit is contained in:
CosminPerRam 2023-01-17 01:21:34 +02:00
parent 21a27fd9cc
commit 6ec2b8952c
4 changed files with 38 additions and 14 deletions

View file

@ -22,6 +22,7 @@ Protocols:
- Valve: The rules field is now a `HashMap<String, String>` instead of a `Vec<ServerRule>` (where the `ServerRule` structure had a name and a value fields). - Valve: The rules field is now a `HashMap<String, String>` instead of a `Vec<ServerRule>` (where the `ServerRule` structure had a name and a value fields).
- Valve: Structs that contained the `players`, `max_players` and `bots` fields have been renamed to `players_online`, `players_maximum` and `players_bots` respectively. - Valve: Structs that contained the `players`, `max_players` and `bots` fields have been renamed to `players_online`, `players_maximum` and `players_bots` respectively.
- Minecraft: Structs that contained the `online_players`, `max_players` and `sample_players` fields have been renamed to `players_online`, `players_maximum` and `players_sample` respectively. - Minecraft: Structs that contained the `online_players`, `max_players` and `sample_players` fields have been renamed to `players_online`, `players_maximum` and `players_sample` respectively.
- Minecraft: The Java query response struct named `Response` has been renamed to `JavaResponse`.
Errors: Errors:
- Besides the `BadGame` error, now no other errors returns details about what happened (as it was quite pointless). - Besides the `BadGame` error, now no other errors returns details about what happened (as it was quite pointless).

View file

@ -43,7 +43,7 @@ pub struct Player {
pub struct JavaResponse { pub struct JavaResponse {
/// Version name, example: "1.19.2". /// Version name, example: "1.19.2".
pub version_name: String, pub version_name: String,
/// Version protocol, example: 760 (for 1.19.2). /// Version protocol, example: 760 (for 1.19.2). Note that for versions below 1.6 this field is always -1.
pub version_protocol: i32, pub version_protocol: i32,
/// Number of server capacity. /// Number of server capacity.
pub players_maximum: u32, pub players_maximum: u32,
@ -66,25 +66,25 @@ pub struct JavaResponse {
/// A Bedrock Edition query response. /// A Bedrock Edition query response.
#[derive(Debug)] #[derive(Debug)]
pub struct BedrockResponse { pub struct BedrockResponse {
/// Server edition. /// Server's edition.
pub edition: String, pub edition: String,
/// Server name. /// Server's name.
pub name: String, pub name: String,
/// Version name, example: "1.19.40". /// Version name, example: "1.19.40".
pub version_name: String, pub version_name: String,
/// Version protocol, example: 760 (for 1.19.2). /// Version protocol, example: 760 (for 1.19.2).
pub version_protocol: String, pub version_protocol: String,
/// Number of server capacity. /// Maximum number of players the server reports it can hold.
pub players_maximum: u32, pub players_maximum: u32,
/// Number of online players. /// Number of players on the server.
pub players_online: u32, pub players_online: u32,
/// Server id. /// Server id.
pub id: Option<String>, pub id: Option<String>,
/// The map. /// Currently running map's name.
pub map: Option<String>, pub map: Option<String>,
/// Game mode. /// Current game mode.
pub game_mode: Option<GameMode>, pub game_mode: Option<GameMode>,
/// Tell's the server type. /// Tells the server type.
pub server_type: Server pub server_type: Server
} }

View file

@ -10,7 +10,7 @@ pub struct TimeoutSettings {
} }
impl TimeoutSettings { impl TimeoutSettings {
/// Construct new settings, passing None will block indefinitely. Passing zero Duration throws GDError::[InvalidInput](GDError::InvalidInput). /// Construct new settings, passing None will block indefinitely. Passing zero Duration throws GDError::[InvalidInput](InvalidInput).
pub fn new(read: Option<Duration>, write: Option<Duration>) -> GDResult<Self> { pub fn new(read: Option<Duration>, write: Option<Duration>) -> GDResult<Self> {
if let Some(read_duration) = read { if let Some(read_duration) = read {
if read_duration == Duration::new(0, 0) { if read_duration == Duration::new(0, 0) {

View file

@ -35,7 +35,7 @@ pub struct ServerInfo {
pub map: String, pub map: String,
/// Name of the folder containing the game files. /// Name of the folder containing the game files.
pub folder: String, pub folder: String,
/// Full name of the game. /// The name of the game.
pub game: String, pub game: String,
/// [Steam Application ID](https://developer.valvesoftware.com/wiki/Steam_Application_ID) of game. /// [Steam Application ID](https://developer.valvesoftware.com/wiki/Steam_Application_ID) of game.
pub appid: u32, pub appid: u32,
@ -72,7 +72,7 @@ pub struct ServerPlayer {
pub name: String, pub name: String,
/// General score. /// General score.
pub score: u32, pub score: u32,
/// How long they've been on the server for. /// How long a player has been in the server (seconds).
pub duration: f32, pub duration: f32,
/// Only for [the ship](https://developer.valvesoftware.com/wiki/The_Ship): deaths count /// Only for [the ship](https://developer.valvesoftware.com/wiki/The_Ship): deaths count
pub deaths: Option<u32>, //the_ship pub deaths: Option<u32>, //the_ship
@ -95,11 +95,11 @@ pub struct ExtraData {
pub port: Option<u16>, pub port: Option<u16>,
/// Server's SteamID. /// Server's SteamID.
pub steam_id: Option<u64>, pub steam_id: Option<u64>,
/// Spectator port number for SourceTV. /// SourceTV's port.
pub tv_port: Option<u16>, pub tv_port: Option<u16>,
/// Name of the spectator server for SourceTV. /// SourceTV's name.
pub tv_name: Option<String>, pub tv_name: Option<String>,
/// Tags that describe the game according to the server. /// Keywords that describe the server according to it.
pub keywords: Option<String>, pub keywords: Option<String>,
/// The server's 64-bit GameID. /// The server's 64-bit GameID.
pub game_id: Option<u64> pub game_id: Option<u64>
@ -250,10 +250,14 @@ pub mod game {
use crate::protocols::valve::types::get_optional_extracted_data; use crate::protocols::valve::types::get_optional_extracted_data;
use super::{Server, ServerPlayer}; use super::{Server, ServerPlayer};
/// A player's details.
#[derive(Debug)] #[derive(Debug)]
pub struct Player { pub struct Player {
/// Player's name.
pub name: String, pub name: String,
/// Player's score.
pub score: u32, pub score: u32,
/// How long a player has been in the server (seconds).
pub duration: f32 pub duration: f32
} }
@ -267,25 +271,44 @@ pub mod game {
} }
} }
/// The query response.
#[derive(Debug)] #[derive(Debug)]
pub struct Response { pub struct Response {
/// Protocol used by the server.
pub protocol: u8, pub protocol: u8,
/// Name of the server.
pub name: String, pub name: String,
/// Map name.
pub map: String, pub map: String,
/// The name of the game.
pub game: String, pub game: String,
/// Number of players on the server.
pub players_online: u8, pub players_online: u8,
/// Details about the server's players (not all players necessarily).
pub players_details: Vec<Player>, pub players_details: Vec<Player>,
/// Maximum number of players the server reports it can hold.
pub players_maximum: u8, pub players_maximum: u8,
/// Number of bots on the server.
pub players_bots: u8, pub players_bots: u8,
/// Dedicated, NonDedicated or SourceTV
pub server_type: Server, pub server_type: Server,
/// Indicates whether the server requires a password.
pub has_password: bool, pub has_password: bool,
/// Indicated whether the server uses VAC.
pub vac_secured: bool, pub vac_secured: bool,
/// Version of the game installed on the server.
pub version: String, pub version: String,
/// The server's reported connection port.
pub port: Option<u16>, pub port: Option<u16>,
/// Server's SteamID.
pub steam_id: Option<u64>, pub steam_id: Option<u64>,
/// SourceTV's connection port.
pub tv_port: Option<u16>, pub tv_port: Option<u16>,
/// SourceTV's name.
pub tv_name: Option<String>, pub tv_name: Option<String>,
/// Keywords that describe the server according to it.
pub keywords: Option<String>, pub keywords: Option<String>,
/// Server's rules.
pub rules: HashMap<String, String> pub rules: HashMap<String, String>
} }