cobble_core/minecraft/launch/detached_launch/
mod.rs

1#[cfg(unix)]
2mod unix;
3#[cfg(windows)]
4mod windows;
5
6#[cfg(unix)]
7pub use unix::GameProcessHandle;
8
9#[cfg(windows)]
10pub use windows::GameProcessHandle;
11
12use crate::error::LaunchResult;
13use async_trait::async_trait;
14use std::process::Command;
15
16/// Trait for game handles to provide the same API on all platforms.
17#[async_trait]
18pub trait GameProcess {
19    /// Should launch the game in a detached state.
20    fn launch(command: Command) -> LaunchResult<Self>
21    where
22        Self: Sized;
23    /// Should stop the game.
24    async fn stop(&self) -> LaunchResult<()>;
25    /// Should wait until the game has exited.
26    async fn wait(&self) -> LaunchResult<()>;
27    /// Should check whether the game is still running.
28    async fn is_stopped(&self) -> LaunchResult<bool>;
29    /// Should check whether the game is still running.
30    fn is_stopped_blocking(&self) -> LaunchResult<bool>;
31}