#[non_exhaustive]pub enum Platform {
Steam {
id: u32,
},
EpicGames {
identifier: String,
},
Oculus,
Origin,
XboxStore {
identifier: String,
},
Other,
}Expand description
A game distribution platform.
Each variant identifies a specific storefront or launcher. The
Platform type is used to locate game installations and create launch
commands on the host system.
This enum is #[non_exhaustive]; new platforms may be added without a
breaking change.
use loadsmith_platform::Platform;
let steam = Platform::Steam { id: 230230 };
assert_eq!(steam.name(), "Steam");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Steam
A Steam game, identified by its Steam App ID.
EpicGames
An Epic Games Store game, identified by its launcher identifier.
Oculus
An Oculus / Meta Store game.
Origin
An Origin (EA App) game.
XboxStore
An Xbox / Microsoft Store game, identified by its package name.
Other
Any other platform that is not explicitly handled.
Implementations§
Source§impl Platform
impl Platform
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
Return the human-readable display name for this platform.
use loadsmith_platform::Platform;
assert_eq!(Platform::Steam { id: 1 }.name(), "Steam");
assert_eq!(Platform::EpicGames { identifier: "x".into() }.name(), "Epic Games");
assert_eq!(Platform::Oculus.name(), "Oculus");
assert_eq!(Platform::Origin.name(), "Origin");
assert_eq!(Platform::XboxStore { identifier: "x".into() }.name(), "Xbox Store");
assert_eq!(Platform::Other.name(), "Other");Sourcepub fn locate_game(&self) -> Result<Option<Utf8PathBuf>>
pub fn locate_game(&self) -> Result<Option<Utf8PathBuf>>
Locate the game directory for this platform’s game, if possible.
Returns Ok(None) when the platform does not support automatic
detection or when the game cannot be found.
use loadsmith_platform::Platform;
let platform = Platform::Steam { id: 730 }; // CS:GO / CS2
match platform.locate_game() {
Ok(Some(path)) => println!("Game found at: {path}"),
_ => println!("Game not found"),
}Sourcepub fn create_launch_command(&self) -> Result<Option<Command>>
pub fn create_launch_command(&self) -> Result<Option<Command>>
Create a platform-specific Command to launch the game, if
supported.
Returns Ok(None) for platforms where launch-command generation is
not implemented.
use loadsmith_platform::Platform;
let platform = Platform::Steam { id: 730 };
if let Ok(Some(cmd)) = platform.create_launch_command() {
println!("Launch command: {cmd:?}");
}Sourcepub fn create_launch_context<'a>(
&'a self,
profile_path: impl Into<Cow<'a, Utf8Path>>,
override_game_path: Option<Utf8PathBuf>,
) -> Result<LaunchContext<'a>>
pub fn create_launch_context<'a>( &'a self, profile_path: impl Into<Cow<'a, Utf8Path>>, override_game_path: Option<Utf8PathBuf>, ) -> Result<LaunchContext<'a>>
Build a LaunchContext for this platform, resolving the game path
and guessing whether Proton is being used.
If override_game_path is Some, it is used directly; otherwise the
game is located via locate_game.
use loadsmith_platform::Platform;
use camino::Utf8PathBuf;
let platform = Platform::Steam { id: 730 };
let ctx = platform.create_launch_context(Utf8PathBuf::from("./profiles"), None);Trait Implementations§
impl Eq for Platform
impl StructuralPartialEq for Platform
Auto Trait Implementations§
impl Freeze for Platform
impl RefUnwindSafe for Platform
impl Send for Platform
impl Sync for Platform
impl Unpin for Platform
impl UnsafeUnpin for Platform
impl UnwindSafe for Platform
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.