pub struct Filter { /* private fields */ }
Expand description
Filter builder - Construct your filter to filter out server results
- Intended to be used with:
MSQClient
andMSQClientBlock
- NOTE: Some filters may or may not work as expected depending on appid/games you try it on. The filter builder methods and string construction generally follows close to the reference listed out in the Valve developer wiki.
- Reference: https://developer.valvesoftware.com/wiki/Master_Server_Query_Protocol#Filter
§Quick Start
use msq::Filter;
let filter = 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"]);
Implementations§
Source§impl Filter
impl Filter
Sourcepub fn as_str(&self) -> String
👎Deprecated since 0.2.0: Replaced with as_string (name change)
pub fn as_str(&self) -> String
Returns a string representing the filters
Sourcepub fn new() -> Filter
pub fn new() -> Filter
Returns a new Filter struct, used for string builder
§Examples
// Filter
use msq::Filter;
let filter = Filter::new()
.appid(240)
.full(false)
.map("de_dust2");
Sourcepub fn nor(self) -> Filter
pub fn nor(self) -> Filter
A special filter, specifies that servers matching any of the following [x] conditions should not be returned.
See end
method to see examples on usage.
Sourcepub fn nand(self) -> Filter
pub fn nand(self) -> Filter
A special filter, specifies that servers matching all of the following [x] conditions should not be returned.
See end
method to see examples on usage.
Sourcepub fn end(self) -> Filter
pub fn end(self) -> Filter
End the special filter (nor, nand) You must use this method after each nor/nand special filter method being used
§Examples
Using the NAND filter:
use msq::Filter;
let filter = Filter::new()
.appid(240)
.nand() // Exclude servers that has de_dust2 AND is empty
.map("de_dust2")
.empty(true)
.end() // Ends the NAND special filter
.gametype(&vec!["friendlyfire", "alltalk"]);
Using the NOR filter:
use msq::Filter;
let filter = Filter::new()
.appid(240)
.nor() // Exclude servers that has de_dust2 OR is empty
.map("de_dust2")
.empty(true)
.end() // Ends the NOR special filter
.gametype(&vec!["friendlyfire", "alltalk"]);
Sourcepub fn dedicated(self, is_dedicated: bool) -> Filter
pub fn dedicated(self, is_dedicated: bool) -> Filter
Filters if the servers running dedicated
§Arguments
is_dedicated
-true
= dedicated,false
= not dedicated
Sourcepub fn secure(self, hasac: bool) -> Filter
pub fn secure(self, hasac: bool) -> Filter
Servers using anti-cheat technology (VAC, but potentially others as well)
§Arguments
hasac
-true
= secure,false
= not secure
Sourcepub fn gamedir(self, modg: &str) -> Filter
pub fn gamedir(self, modg: &str) -> Filter
Servers running the specified modification (ex: cstrike)
§Arguments
modg
- The modification name (ex:cstrike
)
Sourcepub fn map(self, mapn: &str) -> Filter
pub fn map(self, mapn: &str) -> Filter
Servers running the specified map (ex: cs_italy)
§Arguments
mapn
- The current map it’s playing (ex:cs_italy
)
Sourcepub fn linux(self, runslinux: bool) -> Filter
pub fn linux(self, runslinux: bool) -> Filter
Servers running on a Linux platform
§Arguments
runslinux
-true
= Runs on Linux,false
= Does not runs on Linux
Sourcepub fn password(self, protected: bool) -> Filter
pub fn password(self, protected: bool) -> Filter
Servers that are password protected
§Arguments
protected
-true
= Password protected,false
= Not password protected
Sourcepub fn proxy(self, specprox: bool) -> Filter
pub fn proxy(self, specprox: bool) -> Filter
Servers that are spectator proxies
§Arguments
specprox
-true
= A spectator proxies,false
= Not a spectator proxies
Sourcepub fn appid(self, appid: u32) -> Filter
pub fn appid(self, appid: u32) -> Filter
Servers that are running game [appid]
§Arguments
appid
- The appid of the server: (EX:240
(for CS:S))
Sourcepub fn napp(self, appid: u32) -> Filter
pub fn napp(self, appid: u32) -> Filter
Servers that are NOT running game [appid]
§Arguments
appid
- The appid of the server: (EX:240
(for CS:S))
Sourcepub fn whitelisted(self, white: bool) -> Filter
pub fn whitelisted(self, white: bool) -> Filter
Sourcepub fn gamedata(self, tags: &Vec<&str>) -> Filter
pub fn gamedata(self, tags: &Vec<&str>) -> Filter
Servers with all of the given tag(s) in their ‘hidden’ tags (L4D2)
§Arguments
tags
- A vector of strings which represents a tag from sv_tags
Sourcepub fn gamedataor(self, tags: &Vec<&str>) -> Filter
pub fn gamedataor(self, tags: &Vec<&str>) -> Filter
Servers with any of the given tag(s) in their ‘hidden’ tags (L4D2)
§Arguments
tags
- A vector of strings which represents a tag from sv_tags
Sourcepub fn name_match(self, hostname: &str) -> Filter
pub fn name_match(self, hostname: &str) -> Filter
Servers with their hostname matching [hostname] (can use * as a wildcard)
§Arguments
hostname
- String of matching hostname (EX:1.2.*
)
Sourcepub fn version_match(self, ver: &str) -> Filter
pub fn version_match(self, ver: &str) -> Filter
Servers running version [version] (can use * as a wildcard)
§Arguments
ver
- String of matching version
Sourcepub fn collapse_addr_hash(self, one_server: bool) -> Filter
pub fn collapse_addr_hash(self, one_server: bool) -> Filter
Return only one server for each unique IP address matched
§Arguments
one_server
-true
= Return one server