Struct Info

Source
pub struct Info { /* private fields */ }
Expand description

Represents a steam game server.

Ref: https://developer.valvesoftware.com/wiki/Server_queries#A2S_INFO

let server_name = info.name();
let loaded_map = info.map();
let max_players = info.player_max();
let players_online = info.player_count();

Implementations§

Source§

impl Info

Source

pub fn from_bytes(bytes: &[u8]) -> Self

Source§

impl Info

Getters (Immutable)

Source

pub fn name(&self) -> &str

Name of the server.

Examples found in repository?
examples/basic.rs (line 12)
3fn main() {
4    let server =
5        Server::new("127.0.0.1:12345").expect("Connect to dedicated server running Valve game");
6
7    let info = server.info().expect("Get general server information");
8    let players = server.players().expect("Get server player information");
9    let rules = server.rules().expect("Get server rules");
10
11    // Server Information
12    let server_name = info.name();
13    let loaded_map = info.map();
14    let max_players = info.player_max();
15    let players_online = info.player_count();
16
17    println!("Server Name:     {}", &server_name);
18    println!("Map Loaded:      {}", &loaded_map);
19    println!("Players Max:     {}", &max_players);
20    println!("Players Online:  {}", &players_online);
21
22    println!("");
23
24    // Player Information
25    for player in players.iter() {
26        println!("Player: {:?}", player);
27    }
28
29    println!("");
30
31    // Rules
32    for (rule, setting) in rules.iter() {
33        println!("Rule:    {}", rule);
34        println!("Setting: {}", setting);
35    }
36}
Source

pub fn map(&self) -> &str

Map the server has currently loaded.

Examples found in repository?
examples/basic.rs (line 13)
3fn main() {
4    let server =
5        Server::new("127.0.0.1:12345").expect("Connect to dedicated server running Valve game");
6
7    let info = server.info().expect("Get general server information");
8    let players = server.players().expect("Get server player information");
9    let rules = server.rules().expect("Get server rules");
10
11    // Server Information
12    let server_name = info.name();
13    let loaded_map = info.map();
14    let max_players = info.player_max();
15    let players_online = info.player_count();
16
17    println!("Server Name:     {}", &server_name);
18    println!("Map Loaded:      {}", &loaded_map);
19    println!("Players Max:     {}", &max_players);
20    println!("Players Online:  {}", &players_online);
21
22    println!("");
23
24    // Player Information
25    for player in players.iter() {
26        println!("Player: {:?}", player);
27    }
28
29    println!("");
30
31    // Rules
32    for (rule, setting) in rules.iter() {
33        println!("Rule:    {}", rule);
34        println!("Setting: {}", setting);
35    }
36}
Source

pub fn folder(&self) -> &str

Name of the folder containing the game files.

Source

pub fn keywords(&self) -> &Option<String>

Tags that describe the game according to the server (for future use)

Source

pub fn game(&self) -> &str

Full name of the game.

Source

pub fn game_id(&self) -> &Option<LongLong>

The server’s 64-bit GameID. If this is present, a more accurate AppID is present in the low 24 bits. The earlier AppID could have been truncated as it was forced into 16-bit storage.

Source

pub fn game_version(&self) -> &str

Version of the game installed on the server.

Source

pub fn steam_app_id(&self) -> &Short

Steam Application ID of game

Source

pub fn steam_id(&self) -> &Option<LongLong>

Server’s SteamID.

Source

pub fn player_count(&self) -> &Byte

Number of players on the server.

Examples found in repository?
examples/basic.rs (line 15)
3fn main() {
4    let server =
5        Server::new("127.0.0.1:12345").expect("Connect to dedicated server running Valve game");
6
7    let info = server.info().expect("Get general server information");
8    let players = server.players().expect("Get server player information");
9    let rules = server.rules().expect("Get server rules");
10
11    // Server Information
12    let server_name = info.name();
13    let loaded_map = info.map();
14    let max_players = info.player_max();
15    let players_online = info.player_count();
16
17    println!("Server Name:     {}", &server_name);
18    println!("Map Loaded:      {}", &loaded_map);
19    println!("Players Max:     {}", &max_players);
20    println!("Players Online:  {}", &players_online);
21
22    println!("");
23
24    // Player Information
25    for player in players.iter() {
26        println!("Player: {:?}", player);
27    }
28
29    println!("");
30
31    // Rules
32    for (rule, setting) in rules.iter() {
33        println!("Rule:    {}", rule);
34        println!("Setting: {}", setting);
35    }
36}
Source

pub fn player_max(&self) -> &Byte

Maximum number of players the server reports it can hold.

Examples found in repository?
examples/basic.rs (line 14)
3fn main() {
4    let server =
5        Server::new("127.0.0.1:12345").expect("Connect to dedicated server running Valve game");
6
7    let info = server.info().expect("Get general server information");
8    let players = server.players().expect("Get server player information");
9    let rules = server.rules().expect("Get server rules");
10
11    // Server Information
12    let server_name = info.name();
13    let loaded_map = info.map();
14    let max_players = info.player_max();
15    let players_online = info.player_count();
16
17    println!("Server Name:     {}", &server_name);
18    println!("Map Loaded:      {}", &loaded_map);
19    println!("Players Max:     {}", &max_players);
20    println!("Players Online:  {}", &players_online);
21
22    println!("");
23
24    // Player Information
25    for player in players.iter() {
26        println!("Player: {:?}", player);
27    }
28
29    println!("");
30
31    // Rules
32    for (rule, setting) in rules.iter() {
33        println!("Rule:    {}", rule);
34        println!("Setting: {}", setting);
35    }
36}
Source

pub fn bot_count(&self) -> &Byte

Number of bots on the server.

Source

pub fn server_type(&self) -> &ServerType

Indicates the type of server

Source

pub fn platform(&self) -> &Platform

Indicates the operating system of the server

Source

pub fn visibility(&self) -> &Visibility

Indicates whether the server requires a password

Source

pub fn vac(&self) -> &Vac

Specifies whether the server uses VAC

Source

pub fn port(&self) -> &Option<Short>

The server’s game port number

Source

pub fn spectator_name(&self) -> &Option<String>

Name of the spectator server for SourceTV.

Source

pub fn spectator_port(&self) -> &Option<Short>

Spectator port number for SourceTV.

Trait Implementations§

Source§

impl Clone for Info

Source§

fn clone(&self) -> Info

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Info

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Info

Source§

fn eq(&self, other: &Info) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Info

Auto Trait Implementations§

§

impl Freeze for Info

§

impl RefUnwindSafe for Info

§

impl Send for Info

§

impl Sync for Info

§

impl Unpin for Info

§

impl UnwindSafe for Info

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.