Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs overhaul #55

Merged
merged 6 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
rustflags = ["--cfg", "steamlocate_doctest"]
14 changes: 12 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ readme = "README.md"
keywords = ["steam", "vdf", "appmanifest", "directory", "steamapps"]
categories = ["os", "hardware-support", "filesystem", "accessibility"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs", "--cfg", "steamlocate_doctest"]

# TODO: test more features in CI

[features]
Expand All @@ -22,11 +26,17 @@ keyvalues-parser = "0.2"
keyvalues-serde = "0.2"
serde = { version = "1.0", features = ["derive"] }

# TODO: is this really worth making optional? It should be a really small dep
crc = { version = "3.0", optional = true }

[target.'cfg(target_os="windows")'.dependencies]
# Custom cfg used to enable a dependency only needed for doctests
[target."cfg(steamlocate_doctest)".dependencies]
tempfile = "3.8.1"

# Platform-specific dependencies used for locating the steam dir
[target."cfg(target_os=\"windows\")".dependencies]
locate_backend = { package = "winreg", version = "0.51", optional = true }
[target.'cfg(not(target_os="windows"))'.dependencies]
[target."cfg(not(target_os=\"windows\"))".dependencies]
locate_backend = { package = "dirs", version = "5", optional = true }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions examples/appmanifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ fn main() {
let app_id: u32 = args[1].parse().expect("<STEAM_APP_ID> should be a u32");

let steam_dir = SteamDir::locate().unwrap();
match steam_dir.app(app_id) {
Ok(Some(app)) => println!("Found app - {:#?}", app),
match steam_dir.find_app(app_id) {
Ok(Some((app, _library))) => println!("Found app - {:#?}", app),
Ok(None) => println!("No app found for {}", app_id),
Err(err) => println!("Failed reading app: {err}"),
}
Expand Down
46 changes: 9 additions & 37 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,47 +40,27 @@ impl<'library> Iterator for Iter<'library> {
}
}

/// An instance of an installed Steam app.
/// # Example
/// ```ignore
/// # use steamlocate::SteamDir;
/// let mut steamdir = SteamDir::locate().unwrap();
/// let gmod = steamdir.app(&4000);
/// println!("{:#?}", gmod.unwrap());
/// ```
/// ```ignore
/// App (
/// 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
/// )
/// ```
/// Metadata for an installed Steam app
#[derive(Clone, Debug, Deserialize, PartialEq)]
#[cfg_attr(test, derive(serde::Serialize))]
#[non_exhaustive]
#[serde(rename_all = "PascalCase")]
pub struct App {
/// The app ID of this Steam app.
/// The app ID of this Steam app
#[serde(rename = "appid")]
pub app_id: u32,

/// The name of the installation directory of this Steam app.
///
/// Example: `"GarrysMod"`
///
/// This can be resolved to the actual path off of the library
/// The name of the installation directory of this Steam app e.g. `"GarrysMod"`
///
/// ```rust,ignore
/// let app_dir = library.resolve_app_dir(&app);
/// ```
/// If you're trying to get the app's installation directory then take a look at
/// [`Library::resolve_app_dir()`][crate::Library::resolve_app_dir]
#[serde(rename = "installdir")]
pub install_dir: String,

/// The store name of the Steam app.
/// The store name of the Steam app
#[serde(rename = "name")]
pub name: Option<String>,
/// The SteamID64 of the last Steam user that played this game on the filesystem
#[serde(rename = "LastOwner")]
pub last_user: Option<u64>,

pub universe: Option<Universe>,
pub launcher_path: Option<PathBuf>,
Expand Down Expand Up @@ -117,14 +97,6 @@ pub struct App {
pub install_scripts: BTreeMap<u64, PathBuf>,
#[serde(default)]
pub shared_depots: BTreeMap<u64, u64>,

/// The SteamID64 of the last Steam user that played this game on the filesystem.
///
/// This crate supports [steamid-ng](https://docs.rs/steamid-ng) and can automatically convert this to a [SteamID](https://docs.rs/steamid-ng/*/steamid_ng/struct.SteamID.html) for you.
///
/// To enable this support, [use the `steamid_ng` Cargo.toml feature](https://docs.rs/steamlocate/*/steamlocate#using-steamlocate).
#[serde(rename = "LastOwner")]
pub last_user: Option<u64>,
}

impl App {
Expand Down
Loading