pub struct MSQClient { /* private fields */ }
Expand description

The primary MSQ client driver (async)

  • Requires feature: async (Turned on by default)
  • Intended to be used with Filter and Region.
  • This uses the tokio asynchronous UDP Socket to achieve an async MSQ client driver.
  • The non-async/blocking version of this: MSQClientBlock

Quick Start

use msq::{MSQClient, Region, Filter};
use std::io::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let mut client = MSQClient::new().await?;
    client.connect("hl2master.steampowered.com:27011").await?;
    client.max_servers_on_query(256);

    let servers = client
        .query(Region::Europe,  // Restrict query to Europe region
            Filter::new()       // Create a Filter builder
                .appid(240)     // appid of 240 (CS:S)
                .nand()         // Start of NAND special filter
                    .map("de_dust2")     // Map is de_dust2
                    .empty(true)         // Server is empty
                .end()          // End of NAND special filter
                .gametype(&vec!["friendlyfire", "alltalk"])).await?;
    Ok(())
}

Implementations

Create a new MSQClient variable and binds the UDP socket to 0.0.0.0:0

Connect the client to the given master server address/hostname

Arguments
  • master_server_addr - The master server’s hostname/ip address
Example
use msq::MSQClient;
use std::io::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let mut client = MSQClient::new().await?;
    client.connect("hl2master.steampowered.com:27011").await?;
    Ok(())
}

Query with raw bytes

Arguments
  • region_code - Region code in u8 (0x00 - 0x07 / 0xFF)
  • filter_str - Filter in plain string (EX: \\appid\\240\\map\\de_dust2)

Query with specified Region and Filter

Returns a Vec list of IP addresses in strings

Arguments
  • region - Region enum (Region::USEast - Region::Africa / Region::All)
  • filter - Filter builder (EX: Filter::new().appid(240).map("de_dust2"))

Do a single query in one function

Arguments
  • master_server - The address of the master server to fetch the query from
  • max_servers - The maximum amount of servers to query
  • region - Region enum (Region::USEast - Region::Africa / Region::All)
  • filter - Filter builder (EX: Filter::new().appid(240).map("de_dust2"))
Example
use msq::{MSQClient, Region, Filter};
use std::io::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let servers_list = MSQClient::single_query(
            "hl2master.steampowered.com:27011",
            256,
            Region::Europe,
            Filter::new().appid(240)).await?;
    Ok(())
}

Set maximum amount of servers in a given query

Arguments
  • max_servers - Maximum amount of servers in a query

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.