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: 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: The Java query response struct named `Response` has been renamed to `JavaResponse`.
Errors:
- 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 {
/// Version name, example: "1.19.2".
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,
/// Number of server capacity.
pub players_maximum: u32,
@ -66,25 +66,25 @@ pub struct JavaResponse {
/// A Bedrock Edition query response.
#[derive(Debug)]
pub struct BedrockResponse {
/// Server edition.
/// Server's edition.
pub edition: String,
/// Server name.
/// Server's name.
pub name: String,
/// Version name, example: "1.19.40".
pub version_name: String,
/// Version protocol, example: 760 (for 1.19.2).
pub version_protocol: String,
/// Number of server capacity.
/// Maximum number of players the server reports it can hold.
pub players_maximum: u32,
/// Number of online players.
/// Number of players on the server.
pub players_online: u32,
/// Server id.
pub id: Option<String>,
/// The map.
/// Currently running map's name.
pub map: Option<String>,
/// Game mode.
/// Current game mode.
pub game_mode: Option<GameMode>,
/// Tell's the server type.
/// Tells the server type.
pub server_type: Server
}

View file

@ -10,7 +10,7 @@ pub struct 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> {
if let Some(read_duration) = read {
if read_duration == Duration::new(0, 0) {

View file

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