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
andRegion
. - 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§
Source§impl MSQClient
impl MSQClient
Sourcepub async fn new() -> Result<MSQClient>
pub async fn new() -> Result<MSQClient>
Create a new MSQClient variable and binds the UDP socket to 0.0.0.0:0
Sourcepub async fn connect(&mut self, master_server_addr: &str) -> Result<()>
pub async fn connect(&mut self, master_server_addr: &str) -> Result<()>
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(())
}
Sourcepub async fn query_raw(
&mut self,
region_code: u8,
filter_str: &str,
) -> Result<Vec<String>>
pub async fn query_raw( &mut self, region_code: u8, filter_str: &str, ) -> Result<Vec<String>>
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
)
Sourcepub async fn single_query(
master_server: &str,
max_servers: usize,
region: Region,
filter: Filter,
) -> Result<Vec<String>>
pub async fn single_query( master_server: &str, max_servers: usize, region: Region, filter: Filter, ) -> Result<Vec<String>>
Do a single query in one function
§Arguments
master_server
- The address of the master server to fetch the query frommax_servers
- The maximum amount of servers to queryregion
-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(())
}
Sourcepub fn max_servers_on_query(&mut self, max_servers: usize)
pub fn max_servers_on_query(&mut self, max_servers: usize)
Set maximum amount of servers in a given query
§Arguments
max_servers
- Maximum amount of servers in a query
Auto Trait Implementations§
impl !Freeze for MSQClient
impl RefUnwindSafe for MSQClient
impl Send for MSQClient
impl Sync for MSQClient
impl Unpin for MSQClient
impl UnwindSafe for MSQClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more