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

source

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.

source

pub fn apps(&mut self) -> &HashMap<u32, Option<SteamApp>>

Returns a reference to HashMap<u32, Option<SteamApp>> of all SteamApps 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
    )
    ...
}
source

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
)
source

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.

source

pub fn shortcuts(&mut self) -> &[Shortcut]

Returns a listing of all added non-Steam games

Examples found in repository?
examples/shortcuts.rs (line 5)
3
4
5
6
7
fn main() {
    let mut steamdir = steamlocate::SteamDir::locate().unwrap();
    let shortcuts = steamdir.shortcuts();
    println!("Shortcuts - {:#?}", shortcuts);
}
source

pub fn locate() -> Option<SteamDir>

Locates the Steam installation directory on the filesystem and initializes a SteamDir (Linux)

Returns None if no Steam installation can be located.

Examples found in repository?
examples/shortcuts.rs (line 4)
3
4
5
6
7
fn main() {
    let mut steamdir = steamlocate::SteamDir::locate().unwrap();
    let shortcuts = steamdir.shortcuts();
    println!("Shortcuts - {:#?}", shortcuts);
}

Trait Implementations§

source§

impl Clone for SteamDir

source§

fn clone(&self) -> SteamDir

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for SteamDir

source§

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

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

impl Default for SteamDir

source§

fn default() -> SteamDir

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.