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;