Struct steamlocate::SteamDir
source · pub struct SteamDir {
pub path: PathBuf,
/* private fields */
}
Expand description
An instance of a Steam installation.
All functions of this struct will cache their results.
If you’d like to dispose of the cache or get uncached results, just instantiate a new SteamDir
.
Example
let steamdir = SteamDir::locate();
println!("{:#?}", steamdir.unwrap());
SteamDir (
path: "C:\\Program Files (x86)\\Steam"
)
Fields§
§path: PathBuf
The path to the Steam installation directory on this computer.
Example: C:\Program Files (x86)\Steam
Implementations§
source§impl SteamDir
impl SteamDir
sourcepub fn libraryfolders(&mut self) -> &LibraryFolders
pub fn libraryfolders(&mut self) -> &LibraryFolders
Returns a reference to a LibraryFolders
instance.
You can then index LibraryFolders.paths
to get a reference to a Vec<PathBuf>
of every library folder installed on the file system.
This function will cache its result.
sourcepub fn apps(&mut self) -> &HashMap<u32, Option<SteamApp>>
pub fn apps(&mut self) -> &HashMap<u32, Option<SteamApp>>
Returns a reference to HashMap<u32, Option<SteamApp>>
of all SteamApp
s located on this computer.
All Option<SteamApp>
s in this context will be Some
, so you can safely unwrap()
them without panicking.
This function will cache its results and will always return a reference to the same HashMap
.
Example
let mut steamdir = SteamDir::locate().unwrap();
let apps: &HashMap<u32, Option<SteamApp>> = steamdir.apps();
println!("{:#?}", apps);
{
4000: SteamApp (
appid: u32: 4000,
path: PathBuf: "C:\\Program Files (x86)\\steamapps\\common\\GarrysMod",
vdf: <steamy_vdf::Table>,
name: Some(String: "Garry's Mod"),
last_user: Some(u64: 76561198040894045) // This will be a steamid_ng::SteamID if the "steamid_ng" feature is enabled
)
...
}
sourcepub fn app(&mut self, app_id: &u32) -> Option<&SteamApp>
pub fn app(&mut self, app_id: &u32) -> Option<&SteamApp>
Returns a Some
reference to a SteamApp
via its app ID.
If the Steam app is not installed on the system, this will return None
.
This function will cache its (either Some
and None
) result and will always return a reference to the same SteamApp
.
Example
let mut steamdir = SteamDir::locate().unwrap();
let gmod = steamdir.app(&4000);
println!("{:#?}", gmod.unwrap());
SteamApp (
appid: u32: 4000,
path: PathBuf: "C:\\Program Files (x86)\\steamapps\\common\\GarrysMod",
vdf: <steamy_vdf::Table>,
name: Some(String: "Garry's Mod"),
last_user: Some(u64: 76561198040894045) // This will be a steamid_ng::SteamID if the "steamid_ng" feature is enabled
)
sourcepub fn compat_tool(&mut self, app_id: &u32) -> Option<&SteamCompat>
pub fn compat_tool(&mut self, app_id: &u32) -> Option<&SteamCompat>
Returns a Some
reference to a SteamCompat
via its app ID.
If no compatibility tool is configured for the app, this will return None
.
This function will cache its (either Some
and None
) result and will always return a reference to the same SteamCompat
.