- drop stale phase planning comments from launch_profile module headers. - simplify merge_libraries to HashSet<&str> (no string clones). - rewrite coord_key with match_indices (clearer intent). - read /proc/sys/kernel/osrelease on linux for mojang_os_version instead of shelling out to uname; return empty elsewhere. - add comment explaining why is_retryable excludes Parse. - shorten the launch_profile::... paths in launch/mod.rs with top-level use statements. - derive Default on LaunchProfile + nested types so test fixtures use ..Default::default() instead of listing every None field. - inline account_can_launch at its single call site, delete the helper and three tests that exercised trivially-correct one-line logic. - extract get_json_with_raw on HttpClient and save_profile_bytes in instance::loader; collapses three near-identical fetch_X_profile_with_raw helpers and three near-identical 'create dir + write bytes' blocks.
55 lines
1.6 KiB
Rust
55 lines
1.6 KiB
Rust
// quilt installation. same clean approach as fabric (profile json + library
|
|
// downloads). they're basically fabric's cooler sibling.
|
|
|
|
use std::path::Path;
|
|
|
|
use async_trait::async_trait;
|
|
|
|
use super::{GameVersion, ModLoaderInstaller};
|
|
use crate::instance::models::ModLoader;
|
|
use crate::net::{HttpClient, NetError, quilt as quilt_api};
|
|
|
|
pub struct QuiltInstaller;
|
|
|
|
#[async_trait]
|
|
impl ModLoaderInstaller for QuiltInstaller {
|
|
fn loader_type(&self) -> ModLoader {
|
|
ModLoader::Quilt
|
|
}
|
|
|
|
async fn get_game_versions(&self, client: &HttpClient) -> Result<Vec<GameVersion>, NetError> {
|
|
quilt_api::fetch_quilt_game_versions(client).await
|
|
}
|
|
|
|
async fn get_versions(
|
|
&self,
|
|
client: &HttpClient,
|
|
game_version: &str,
|
|
) -> Result<Vec<String>, NetError> {
|
|
let loader_versions = quilt_api::fetch_quilt_versions(client, game_version).await?;
|
|
Ok(loader_versions
|
|
.into_iter()
|
|
.map(|lv| lv.loader.version)
|
|
.collect())
|
|
}
|
|
|
|
async fn install(
|
|
&self,
|
|
client: &HttpClient,
|
|
game_version: &str,
|
|
loader_version: &str,
|
|
_instance_dir: &Path,
|
|
meta_dir: &Path,
|
|
) -> Result<(), NetError> {
|
|
let (profile, raw_bytes) =
|
|
quilt_api::fetch_quilt_profile_with_raw(client, game_version, loader_version).await?;
|
|
quilt_api::download_quilt_libraries(client, &profile, meta_dir).await?;
|
|
super::save_profile_bytes(
|
|
meta_dir,
|
|
&format!("quilt-{game_version}-{loader_version}.json"),
|
|
&raw_bytes,
|
|
)?;
|
|
Ok(())
|
|
}
|
|
}
|