pub struct Launcher { /* private fields */ }Implementations§
Source§impl Launcher
impl Launcher
pub fn new(options: LaunchOptions) -> Self
pub fn options(&self) -> &LaunchOptions
pub fn game_data(&self) -> Option<&GameData>
Sourcepub async fn download_game(
&mut self,
event_tx: Sender<LaunchEvent>,
) -> Result<(), LaunchError>
pub async fn download_game( &mut self, event_tx: Sender<LaunchEvent>, ) -> Result<(), LaunchError>
Download, verify, and optionally install a mod loader for the configured
Minecraft version. Stores the result in self.game_data.
Emits progress events on event_tx. After this call,
Launcher::launch can be invoked without downloading again.
If there is no internet connection and a valid cache exists, the cache
is loaded without network access. If there is no cache either, returns
LaunchError::NoInternetNoCache.
Sourcepub async fn launch(
&self,
event_tx: Sender<LaunchEvent>,
) -> Result<Child, LaunchError>
pub async fn launch( &self, event_tx: Sender<LaunchEvent>, ) -> Result<Child, LaunchError>
Assemble the Java command line and spawn the Minecraft process.
Resolves game data from self.game_data (set by Launcher::download_game)
or, if absent, from the persisted cache on disk. Returns
LaunchError::GameDataNotReady if neither is available.
Stdout and stderr are piped; each line is forwarded as a
LaunchEvent::Data event. The caller is responsible for calling
child.wait() and emitting LaunchEvent::Close when appropriate.
Sourcepub async fn start(
&mut self,
event_tx: Sender<LaunchEvent>,
) -> Result<Child, LaunchError>
pub async fn start( &mut self, event_tx: Sender<LaunchEvent>, ) -> Result<Child, LaunchError>
Download the game and immediately launch it.
Equivalent to download_game followed by launch. Returns the
tokio::process::Child handle so the caller can monitor or kill
the process.
To receive a LaunchEvent::Close event, wait on the returned child
and send it yourself:
let code = child.wait().await?.code().unwrap_or(-1);
let _ = tx.send(LaunchEvent::Close(code)).await;Sourcepub fn is_corrupt_crash(exit_code: i32, logs: &[String]) -> bool
pub fn is_corrupt_crash(exit_code: i32, logs: &[String]) -> bool
Heuristically detect whether a game crash was caused by a corrupt or incomplete installation.
Returns true when exit_code is non-zero and at least one log
line matches a known corrupt-installation pattern. The caller can use
this as a signal to force a full re-check by calling download_game()
with skip_bundle_check: false on the next attempt.
§Example
let code = child.wait().await?.code().unwrap_or(-1);
let lines: Vec<String> = /* collected LaunchEvent::Data lines */;
if Launcher::is_corrupt_crash(code, &lines) {
// Re-run download_game with skip_bundle_check: false
}