diff --git a/app/lib/src/rust/api/shared_resources/collection.dart b/app/lib/src/rust/api/shared_resources/collection.dart index 7f13a77a..4d01e22d 100644 --- a/app/lib/src/rust/api/shared_resources/collection.dart +++ b/app/lib/src/rust/api/shared_resources/collection.dart @@ -42,12 +42,6 @@ class Collection extends RustOpaque { advancedOptions: advancedOptions, hint: hint); - /// Downloads game(alos verifies) - Future downloadGame({dynamic hint}) => - RustLib.instance.api.collectionDownloadGame( - that: this, - ); - Future gameDirectory({dynamic hint}) => RustLib.instance.api.collectionGameDirectory( that: this, @@ -61,19 +55,24 @@ class Collection extends RustOpaque { that: this, ); - Future getLoader({dynamic hint}) => - RustLib.instance.api.collectionGetLoader( - that: this, - ); - /// SIDE-EFFECT: put `launch_args` into Struct Future launchGame({dynamic hint}) => RustLib.instance.api.collectionLaunchGame( that: this, ); + Future save({dynamic hint}) => RustLib.instance.api.collectionSave( + that: this, + ); + static Future> scan({dynamic hint}) => RustLib.instance.api.collectionScan(hint: hint); + + /// Downloads game(alos verifies) + Future verifyAndDownloadGame({dynamic hint}) => + RustLib.instance.api.collectionVerifyAndDownloadGame( + that: this, + ); } class AdvancedOptions { diff --git a/app/lib/src/rust/frb_generated.dart b/app/lib/src/rust/frb_generated.dart index 6d74941d..7c278f52 100644 --- a/app/lib/src/rust/frb_generated.dart +++ b/app/lib/src/rust/frb_generated.dart @@ -83,9 +83,6 @@ abstract class RustLibApi extends BaseApi { AdvancedOptions? advancedOptions, dynamic hint}); - Future collectionDownloadGame( - {required Collection that, dynamic hint}); - Future collectionGameDirectory( {required Collection that, dynamic hint}); @@ -94,13 +91,15 @@ abstract class RustLibApi extends BaseApi { Future collectionGetCollectionId( {required Collection that, dynamic hint}); - Future collectionGetLoader( - {required Collection that, dynamic hint}); - Future collectionLaunchGame({required Collection that, dynamic hint}); + Future collectionSave({required Collection that, dynamic hint}); + Future> collectionScan({dynamic hint}); + Future collectionVerifyAndDownloadGame( + {required Collection that, dynamic hint}); + Future createCollection( {required String displayName, required VersionMetadata versionMetadata, @@ -211,32 +210,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { ], ); - @override - Future collectionDownloadGame( - {required Collection that, dynamic hint}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { - var arg0 = - cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockCollection( - that); - return wire.wire_Collection_download_game(port_, arg0); - }, - codec: DcoCodec( - decodeSuccessData: dco_decode_launch_args, - decodeErrorData: dco_decode_AnyhowException, - ), - constMeta: kCollectionDownloadGameConstMeta, - argValues: [that], - apiImpl: this, - hint: hint, - )); - } - - TaskConstMeta get kCollectionDownloadGameConstMeta => const TaskConstMeta( - debugName: "Collection_download_game", - argNames: ["that"], - ); - @override Future collectionGameDirectory( {required Collection that, dynamic hint}) { @@ -314,53 +287,52 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { ); @override - Future collectionGetLoader( - {required Collection that, dynamic hint}) { + Future collectionLaunchGame({required Collection that, dynamic hint}) { return handler.executeNormal(NormalTask( callFfi: (port_) { var arg0 = - cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockCollection( + cst_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockCollection( that); - return wire.wire_Collection_get_loader(port_, arg0); + return wire.wire_Collection_launch_game(port_, arg0); }, codec: DcoCodec( - decodeSuccessData: dco_decode_storage_loader, + decodeSuccessData: dco_decode_unit, decodeErrorData: dco_decode_AnyhowException, ), - constMeta: kCollectionGetLoaderConstMeta, + constMeta: kCollectionLaunchGameConstMeta, argValues: [that], apiImpl: this, hint: hint, )); } - TaskConstMeta get kCollectionGetLoaderConstMeta => const TaskConstMeta( - debugName: "Collection_get_loader", + TaskConstMeta get kCollectionLaunchGameConstMeta => const TaskConstMeta( + debugName: "Collection_launch_game", argNames: ["that"], ); @override - Future collectionLaunchGame({required Collection that, dynamic hint}) { + Future collectionSave({required Collection that, dynamic hint}) { return handler.executeNormal(NormalTask( callFfi: (port_) { var arg0 = - cst_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockCollection( + cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockCollection( that); - return wire.wire_Collection_launch_game(port_, arg0); + return wire.wire_Collection_save(port_, arg0); }, codec: DcoCodec( decodeSuccessData: dco_decode_unit, decodeErrorData: dco_decode_AnyhowException, ), - constMeta: kCollectionLaunchGameConstMeta, + constMeta: kCollectionSaveConstMeta, argValues: [that], apiImpl: this, hint: hint, )); } - TaskConstMeta get kCollectionLaunchGameConstMeta => const TaskConstMeta( - debugName: "Collection_launch_game", + TaskConstMeta get kCollectionSaveConstMeta => const TaskConstMeta( + debugName: "Collection_save", argNames: ["that"], ); @@ -386,6 +358,33 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { argNames: [], ); + @override + Future collectionVerifyAndDownloadGame( + {required Collection that, dynamic hint}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + var arg0 = + cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockCollection( + that); + return wire.wire_Collection_verify_and_download_game(port_, arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_launch_args, + decodeErrorData: dco_decode_AnyhowException, + ), + constMeta: kCollectionVerifyAndDownloadGameConstMeta, + argValues: [that], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kCollectionVerifyAndDownloadGameConstMeta => + const TaskConstMeta( + debugName: "Collection_verify_and_download_game", + argNames: ["that"], + ); + @override Future createCollection( {required String displayName, diff --git a/app/lib/src/rust/frb_generated.io.dart b/app/lib/src/rust/frb_generated.io.dart index 3a6ddb31..459a130f 100644 --- a/app/lib/src/rust/frb_generated.io.dart +++ b/app/lib/src/rust/frb_generated.io.dart @@ -1242,22 +1242,6 @@ class RustLibWire implements BaseWire { ffi.Pointer, ffi.Pointer)>(); - void wire_Collection_download_game( - int port_, - int that, - ) { - return _wire_Collection_download_game( - port_, - that, - ); - } - - late final _wire_Collection_download_gamePtr = - _lookup>( - 'frbgen_era_connect_wire_Collection_download_game'); - late final _wire_Collection_download_game = - _wire_Collection_download_gamePtr.asFunction(); - void wire_Collection_game_directory( int port_, int that, @@ -1305,37 +1289,37 @@ class RustLibWire implements BaseWire { _wire_Collection_get_collection_idPtr .asFunction(); - void wire_Collection_get_loader( + void wire_Collection_launch_game( int port_, int that, ) { - return _wire_Collection_get_loader( + return _wire_Collection_launch_game( port_, that, ); } - late final _wire_Collection_get_loaderPtr = + late final _wire_Collection_launch_gamePtr = _lookup>( - 'frbgen_era_connect_wire_Collection_get_loader'); - late final _wire_Collection_get_loader = - _wire_Collection_get_loaderPtr.asFunction(); + 'frbgen_era_connect_wire_Collection_launch_game'); + late final _wire_Collection_launch_game = + _wire_Collection_launch_gamePtr.asFunction(); - void wire_Collection_launch_game( + void wire_Collection_save( int port_, int that, ) { - return _wire_Collection_launch_game( + return _wire_Collection_save( port_, that, ); } - late final _wire_Collection_launch_gamePtr = + late final _wire_Collection_savePtr = _lookup>( - 'frbgen_era_connect_wire_Collection_launch_game'); - late final _wire_Collection_launch_game = - _wire_Collection_launch_gamePtr.asFunction(); + 'frbgen_era_connect_wire_Collection_save'); + late final _wire_Collection_save = + _wire_Collection_savePtr.asFunction(); void wire_Collection_scan( int port_, @@ -1351,6 +1335,23 @@ class RustLibWire implements BaseWire { late final _wire_Collection_scan = _wire_Collection_scanPtr.asFunction(); + void wire_Collection_verify_and_download_game( + int port_, + int that, + ) { + return _wire_Collection_verify_and_download_game( + port_, + that, + ); + } + + late final _wire_Collection_verify_and_download_gamePtr = + _lookup>( + 'frbgen_era_connect_wire_Collection_verify_and_download_game'); + late final _wire_Collection_verify_and_download_game = + _wire_Collection_verify_and_download_gamePtr + .asFunction(); + void wire_create_collection( int port_, ffi.Pointer display_name, diff --git a/app/lib/src/rust/frb_generated.web.dart b/app/lib/src/rust/frb_generated.web.dart index 2ac0d564..2e0bbb86 100644 --- a/app/lib/src/rust/frb_generated.web.dart +++ b/app/lib/src/rust/frb_generated.web.dart @@ -1059,9 +1059,6 @@ class RustLibWire implements BaseWire { wasmModule.wire_Collection_create( port_, display_name, version_metadata, mod_loader, advanced_options); - void wire_Collection_download_game(NativePortType port_, Object that) => - wasmModule.wire_Collection_download_game(port_, that); - void wire_Collection_game_directory(NativePortType port_, Object that) => wasmModule.wire_Collection_game_directory(port_, that); @@ -1071,15 +1068,19 @@ class RustLibWire implements BaseWire { void wire_Collection_get_collection_id(NativePortType port_, Object that) => wasmModule.wire_Collection_get_collection_id(port_, that); - void wire_Collection_get_loader(NativePortType port_, Object that) => - wasmModule.wire_Collection_get_loader(port_, that); - void wire_Collection_launch_game(NativePortType port_, Object that) => wasmModule.wire_Collection_launch_game(port_, that); + void wire_Collection_save(NativePortType port_, Object that) => + wasmModule.wire_Collection_save(port_, that); + void wire_Collection_scan(NativePortType port_) => wasmModule.wire_Collection_scan(port_); + void wire_Collection_verify_and_download_game( + NativePortType port_, Object that) => + wasmModule.wire_Collection_verify_and_download_game(port_, that); + void wire_create_collection( NativePortType port_, String display_name, @@ -1162,9 +1163,6 @@ class RustLibWasmModule implements WasmModule { List? mod_loader, List? advanced_options); - external void wire_Collection_download_game( - NativePortType port_, Object that); - external void wire_Collection_game_directory( NativePortType port_, Object that); @@ -1173,12 +1171,15 @@ class RustLibWasmModule implements WasmModule { external void wire_Collection_get_collection_id( NativePortType port_, Object that); - external void wire_Collection_get_loader(NativePortType port_, Object that); - external void wire_Collection_launch_game(NativePortType port_, Object that); + external void wire_Collection_save(NativePortType port_, Object that); + external void wire_Collection_scan(NativePortType port_); + external void wire_Collection_verify_and_download_game( + NativePortType port_, Object that); + external void wire_create_collection( NativePortType port_, String display_name, diff --git a/app/rust/src/api/backend_exclusive/download.rs b/app/rust/src/api/backend_exclusive/download.rs index 521cd616..8464a3e4 100644 --- a/app/rust/src/api/backend_exclusive/download.rs +++ b/app/rust/src/api/backend_exclusive/download.rs @@ -12,7 +12,7 @@ use std::{ use anyhow::{bail, Context}; use bytes::{BufMut, Bytes, BytesMut}; use futures::{future::BoxFuture, StreamExt}; -use log::error; +use log::{debug, error}; use reqwest::Url; use tokio::{ fs::File, @@ -171,7 +171,7 @@ pub async fn execute_and_progress( download_args: DownloadArgs<'_>, bias: DownloadBias, ) -> anyhow::Result<()> { - println!("run_download"); + debug!("receiving download request"); let handles = download_args.handles; let calculate_speed = download_args.is_size; let download_complete = Arc::new(AtomicBool::new(false)); @@ -197,6 +197,8 @@ pub async fn execute_and_progress( download_complete.store(true, Ordering::Release); output.await?; + debug!("finish download request"); + // DOWNLOAD_PROGRESS.remove(&id); Ok(()) diff --git a/app/rust/src/api/backend_exclusive/mod_management/mods.rs b/app/rust/src/api/backend_exclusive/mod_management/mods.rs index b5fbf22e..ba640bab 100644 --- a/app/rust/src/api/backend_exclusive/mod_management/mods.rs +++ b/app/rust/src/api/backend_exclusive/mod_management/mods.rs @@ -148,7 +148,7 @@ pub struct ModManager { pub mods: Vec, #[serde(skip)] cache: Option>, - #[serde(skip)] + game_directory: PathBuf, mod_loader: Option, target_game_version: VersionMetadata, @@ -180,7 +180,7 @@ impl ModManager { target_game_version, } } - pub fn get_download(&mut self) -> anyhow::Result { + pub fn get_download(&self) -> anyhow::Result { let current_size = Arc::new(AtomicUsize::new(0)); let total_size = Arc::new(AtomicUsize::new(0)); let base_path = self.game_directory.join("mods"); @@ -331,8 +331,12 @@ impl ModManager { tag: Vec, mod_override: &Vec, ) -> anyhow::Result<()> { + let mut is_fabric_api = false; let mod_metadata = match &minecraft_mod_data { MinecraftModData::Modrinth(minecraft_mod) => { + if minecraft_mod.project_id == "P7dR8mSH" { + is_fabric_api = true; + } let project = FERINTH.get_project(&minecraft_mod.project_id).await?; ModMetadata { name: project.title, @@ -365,7 +369,9 @@ impl ModManager { if !self.mods.contains(&mod_metadata) { self.mod_dependencies_resolve(&mod_metadata.mod_data, mod_override) .await?; - self.mods.push(mod_metadata); + if !is_fabric_api { + self.mods.push(mod_metadata); + } } Ok(()) } @@ -430,6 +436,15 @@ impl ModManager { let mut mod_loader_filter = versions .into_iter() + .map(|x| { + match x { + MinecraftModData::Modrinth(mut ver) => { + ver.files = ver.files.into_iter().filter(|x| x.primary).collect::>(); + ver.into() + }, + MinecraftModData::Curseforge {..} => x, + } + }) .filter(|x| { if mod_override.contains(&ModOverride::IgnoreModLoader) { true @@ -490,13 +505,12 @@ impl ModManager { collection_mod_loader ); } - let version = mod_loader_filter + let collection_game_version = all_game_version + .iter() + .find(|x| x.id == self.target_game_version.id) + .expect("somehow can't find game versions"); + let mut possible_versions = mod_loader_filter .filter(|x| { - let collection_game_version = all_game_version - .iter() - .find(|x| x.id == self.target_game_version.id) - .expect("somehow can't find game versions"); - let supported_game_versions = match x { MinecraftModData::Modrinth(x) => x .game_versions @@ -515,29 +529,48 @@ impl ModManager { x if x.contains(&ModOverride::IgnoreMinorGameVersion) && collection_game_version.version_type == VersionType::Release => { - let target_semver = - semver::Version::parse(&collection_game_version.id).map(|x| x.minor); - supported_game_versions.iter().any(|x| { - if let (Ok(supported_version), Ok(target)) = ( - semver::Version::parse(&x.id).map(|x| x.minor), - target_semver.as_ref(), - ) { - &supported_version == target - } else { - x.id == collection_game_version.id - } - }) + supported_game_versions + .iter() + .any(|x| minor_game_check(x, &collection_game_version.id)) } _ => supported_game_versions .iter() .any(|x| x.id == collection_game_version.id), } }) - .max_by_key(|x| match x { - MinecraftModData::Modrinth(x) => x.date_published, - MinecraftModData::Curseforge { data, .. } => data.file_date, - }); - + .collect::>(); + possible_versions.sort_by_key(|x| match x { + MinecraftModData::Modrinth(x) => x.date_published, + MinecraftModData::Curseforge { data, .. } => data.file_date, + }); + let version = if mod_override.contains(&ModOverride::IgnoreMinorGameVersion) { + // strict game check + if let Some(x) = possible_versions.iter().find(|x| { + let supported_game_versions = match x { + MinecraftModData::Modrinth(x) => x + .game_versions + .iter() + .filter_map(|x| all_game_version.iter().find(|y| &y.id == x)) + .collect::>(), + MinecraftModData::Curseforge { data, .. } => data + .game_versions + .iter() + .filter_map(|x| all_game_version.iter().find(|y| &y.id == x)) + .collect::>(), + }; + supported_game_versions + .iter() + .any(|x| x.id == collection_game_version.id) + }) { + Some(x.clone()) + } + // loosen it a bit + else { + possible_versions.into_iter().next() + } + } else { + possible_versions.into_iter().next() + }; self.add_mod( version .context("Can't find suitible mod with mod loader and version constraints")? @@ -551,6 +584,17 @@ impl ModManager { } } +fn minor_game_check(version: &&VersionMetadata, game_id: &str) -> bool { + let target_semver = semver::Version::parse(game_id).map(|x| x.minor); + if let (Ok(supported_version), Ok(target)) = ( + semver::Version::parse(&version.id).map(|x| x.minor), + target_semver.as_ref(), + ) { + &supported_version == target + } else { + version.id == game_id + } +} async fn hashes_validate(path: impl AsRef, vec: &[&str]) -> bool { for p in vec { let is_ok = validate_sha1(path.as_ref(), p).await.is_ok(); @@ -564,6 +608,7 @@ async fn hashes_validate(path: impl AsRef, vec: &[&str]) -> bool { /// `IgnoreMinorGameVersion` will behave like `IgnoreAllGameVersion` if operated on snapshots. #[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)] pub enum ModOverride { + // ignore minor game version, using a latest-fully-compatiable mod available IgnoreMinorGameVersion, IgnoreAllGameVersion, QuiltFabricCompatibility, diff --git a/app/rust/src/api/shared_resources/collection.rs b/app/rust/src/api/shared_resources/collection.rs index 2591ce6d..c234c66b 100644 --- a/app/rust/src/api/shared_resources/collection.rs +++ b/app/rust/src/api/shared_resources/collection.rs @@ -38,10 +38,8 @@ pub struct Collection { pub played_time: Duration, pub advanced_options: Option, - #[serde(skip)] pub entry_path: PathBuf, pub mod_manager: ModManager, - #[serde(skip)] launch_args: Option, } @@ -51,6 +49,7 @@ pub struct CollectionId(pub String); const COLLECTION_FILE_NAME: &str = "collection.json"; const COLLECTION_BASE: &str = "collections"; +/// if a method has `&mut self`, remember to call `self.save()` to actually save it! impl Collection { /// Creates a collection and return a collection with its loader attached pub fn create( @@ -81,7 +80,7 @@ impl Collection { launch_args: None, }; - loader.save(&collection)?; + collection.save()?; Ok(collection) } @@ -99,6 +98,7 @@ impl Collection { self.mod_manager .add_project(project.into(), tag, mod_override.unwrap_or(&Vec::new())) .await?; + self.save()?; Ok(()) } #[frb(ignore)] @@ -112,11 +112,12 @@ impl Collection { self.mod_manager .add_project(project.into(), tag, mod_override.unwrap_or(&Vec::new())) .await?; + self.save()?; Ok(()) } #[frb(ignore)] - pub async fn download_mods(&mut self) -> anyhow::Result<()> { + pub async fn download_mods(&self) -> anyhow::Result<()> { let id = self.get_collection_id(); let download_args = self.mod_manager.get_download()?; execute_and_progress(id, download_args, DownloadBias::default()).await?; @@ -126,13 +127,19 @@ impl Collection { /// SIDE-EFFECT: put `launch_args` into Struct pub async fn launch_game(&mut self) -> anyhow::Result<()> { if self.launch_args.is_none() { - self.launch_args = Some(self.download_game().await?); + self.launch_args = Some(self.verify_and_download_game().await?); + self.save()?; } vanilla::launcher::launch_game(&self.launch_args.as_ref().unwrap()).await } - /// Downloads game(alos verifies) - pub async fn download_game(&self) -> anyhow::Result { + #[frb(ignore)] + pub async unsafe fn launch_game_unchecked(&self) -> anyhow::Result<()> { + vanilla::launcher::launch_game(&self.launch_args.as_ref().unwrap()).await + } + + /// Downloads game(also verifies) + pub async fn verify_and_download_game(&self) -> anyhow::Result { let mod_loader_clone = self.mod_loader.clone(); let p = if let Some(mod_loader) = mod_loader_clone { match mod_loader.mod_loader_type { @@ -155,6 +162,7 @@ impl Collection { } pub fn get_collection_id(&self) -> CollectionId { + dbg!(&self.entry_path); CollectionId( self.entry_path .file_name() @@ -164,9 +172,10 @@ impl Collection { ) } - pub fn get_loader(&self) -> anyhow::Result { + pub fn save(&self) -> anyhow::Result<()> { let p = Self::create_loader(&self.display_name)?; - Ok(p) + p.save(&self)?; + Ok(()) } fn create_loader(display_name: &str) -> std::io::Result { @@ -236,6 +245,7 @@ impl Collection { info!("Succesfully scanned the mods"); collection.entry_path = path; loader.save(&collection)?; + dbg!(&loader.load::().unwrap()); loaders.push(loader); } } diff --git a/app/rust/src/api/shared_resources/entry.rs b/app/rust/src/api/shared_resources/entry.rs index d23c6125..a9563cab 100644 --- a/app/rust/src/api/shared_resources/entry.rs +++ b/app/rust/src/api/shared_resources/entry.rs @@ -152,48 +152,28 @@ pub async fn create_collection( mod_loader: Option, advanced_options: Option, ) -> anyhow::Result<()> { - let p = STORAGE.collections.read().await; - dbg!(p.last().as_ref().map(|x| &x.mod_manager.mods)); - + // let mut p = STORAGE.collections.write().await; + // let collection = p.last_mut().unwrap(); + // dbg!(&collection); // NOTE: testing purposes let mod_loader = Some(ModLoader { - mod_loader_type: ModLoaderType::NeoForge, + mod_loader_type: ModLoaderType::Quilt, version: None, }); let version_metadata = get_versions() .await? .into_iter() - .find(|x| x.id == "1.20.4") + .find(|x| x.id == "1.20.2") .unwrap(); let mut collection = Collection::create(display_name, version_metadata, mod_loader, advanced_options)?; - collection - .add_curseforge_mod( - 448233, - vec![], - Some(&vec![ - ModOverride::QuiltFabricCompatibility, - ModOverride::IgnoreMinorGameVersion, - ]), - ) - .await?; - collection.download_mods().await?; - dbg!(&collection.mod_manager.mods); - let loader = collection.get_loader()?; - - loader.save(&collection)?; - - info!( - "Successfully created collection basic file at {}", - collection.entry_path.display() - ); let id = collection.get_collection_id(); let download_handle = tokio::spawn(async move { loop { if let Some(x) = DOWNLOAD_PROGRESS.get(&id) { if x.percentages >= 100.0 { - break; + // break; } debug!("{:#?}", &*x); } @@ -201,13 +181,19 @@ pub async fn create_collection( } }); - collection.download_game().await?; + info!( + "Successfully created collection basic file at {}", + collection.entry_path.display() + ); + + collection.download_mods().await?; + dbg!(&collection.mod_manager.mods); - download_handle.await?; + collection.launch_game().await?; info!("Successfully finished downloading game"); - collection.launch_game().await?; + download_handle.await?; Ok(()) } diff --git a/app/rust/src/frb_generated.io.rs b/app/rust/src/frb_generated.io.rs index eef32027..e3743ab9 100644 --- a/app/rust/src/frb_generated.io.rs +++ b/app/rust/src/frb_generated.io.rs @@ -693,11 +693,6 @@ pub extern "C" fn frbgen_era_connect_wire_Collection_create( ) } -#[no_mangle] -pub extern "C" fn frbgen_era_connect_wire_Collection_download_game(port_: i64, that: usize) { - wire_Collection_download_game_impl(port_, that) -} - #[no_mangle] pub extern "C" fn frbgen_era_connect_wire_Collection_game_directory(port_: i64, that: usize) { wire_Collection_game_directory_impl(port_, that) @@ -714,13 +709,13 @@ pub extern "C" fn frbgen_era_connect_wire_Collection_get_collection_id(port_: i6 } #[no_mangle] -pub extern "C" fn frbgen_era_connect_wire_Collection_get_loader(port_: i64, that: usize) { - wire_Collection_get_loader_impl(port_, that) +pub extern "C" fn frbgen_era_connect_wire_Collection_launch_game(port_: i64, that: usize) { + wire_Collection_launch_game_impl(port_, that) } #[no_mangle] -pub extern "C" fn frbgen_era_connect_wire_Collection_launch_game(port_: i64, that: usize) { - wire_Collection_launch_game_impl(port_, that) +pub extern "C" fn frbgen_era_connect_wire_Collection_save(port_: i64, that: usize) { + wire_Collection_save_impl(port_, that) } #[no_mangle] @@ -728,6 +723,14 @@ pub extern "C" fn frbgen_era_connect_wire_Collection_scan(port_: i64) { wire_Collection_scan_impl(port_) } +#[no_mangle] +pub extern "C" fn frbgen_era_connect_wire_Collection_verify_and_download_game( + port_: i64, + that: usize, +) { + wire_Collection_verify_and_download_game_impl(port_, that) +} + #[no_mangle] pub extern "C" fn frbgen_era_connect_wire_create_collection( port_: i64, diff --git a/app/rust/src/frb_generated.rs b/app/rust/src/frb_generated.rs index 8c0956d4..914d61ff 100644 --- a/app/rust/src/frb_generated.rs +++ b/app/rust/src/frb_generated.rs @@ -81,35 +81,6 @@ fn wire_Collection_create_impl( }, ) } -fn wire_Collection_download_game_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, - that: impl CstDecode< - RustOpaqueNom>, - >, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( - flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "Collection_download_game", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, - }, - move || { - let api_that = that.cst_decode(); - move |context| async move { - transform_result_dco( - (move || async move { - let api_that = api_that.rust_auto_opaque_decode_ref(); - crate::api::shared_resources::collection::Collection::download_game( - &api_that, - ) - .await - })() - .await, - ) - } - }, - ) -} fn wire_Collection_game_directory_impl( port_: flutter_rust_bridge::for_generated::MessagePort, that: impl CstDecode< @@ -182,54 +153,54 @@ fn wire_Collection_get_collection_id_impl( }, ) } -fn wire_Collection_get_loader_impl( +fn wire_Collection_launch_game_impl( port_: flutter_rust_bridge::for_generated::MessagePort, that: impl CstDecode< RustOpaqueNom>, >, ) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "Collection_get_loader", + debug_name: "Collection_launch_game", port: Some(port_), mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, }, move || { let api_that = that.cst_decode(); - move |context| { - transform_result_dco((move || { - let api_that = api_that.rust_auto_opaque_decode_ref(); - crate::api::shared_resources::collection::Collection::get_loader(&api_that) - })()) + move |context| async move { + transform_result_dco( + (move || async move { + let mut api_that = api_that.rust_auto_opaque_decode_ref_mut(); + crate::api::shared_resources::collection::Collection::launch_game( + &mut api_that, + ) + .await + })() + .await, + ) } }, ) } -fn wire_Collection_launch_game_impl( +fn wire_Collection_save_impl( port_: flutter_rust_bridge::for_generated::MessagePort, that: impl CstDecode< RustOpaqueNom>, >, ) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "Collection_launch_game", + debug_name: "Collection_save", port: Some(port_), mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, }, move || { let api_that = that.cst_decode(); - move |context| async move { - transform_result_dco( - (move || async move { - let mut api_that = api_that.rust_auto_opaque_decode_ref_mut(); - crate::api::shared_resources::collection::Collection::launch_game( - &mut api_that, - ) - .await - })() - .await, - ) + move |context| { + transform_result_dco((move || { + let api_that = api_that.rust_auto_opaque_decode_ref(); + crate::api::shared_resources::collection::Collection::save(&api_that) + })()) } }, ) @@ -250,6 +221,29 @@ fn wire_Collection_scan_impl(port_: flutter_rust_bridge::for_generated::MessageP }, ) } +fn wire_Collection_verify_and_download_game_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + that: impl CstDecode< + RustOpaqueNom>, + >, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Collection_verify_and_download_game", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let api_that = that.cst_decode(); + move |context| async move { + transform_result_dco((move || async move { + let api_that = api_that.rust_auto_opaque_decode_ref(); + crate::api::shared_resources::collection::Collection::verify_and_download_game(&api_that).await + })().await) + } + }, + ) +} fn wire_create_collection_impl( port_: flutter_rust_bridge::for_generated::MessagePort, display_name: impl CstDecode, diff --git a/app/rust/src/frb_generated.web.rs b/app/rust/src/frb_generated.web.rs index 00ea4a2d..0d6c7010 100644 --- a/app/rust/src/frb_generated.web.rs +++ b/app/rust/src/frb_generated.web.rs @@ -640,14 +640,6 @@ pub fn wire_Collection_create( ) } -#[wasm_bindgen] -pub fn wire_Collection_download_game( - port_: flutter_rust_bridge::for_generated::MessagePort, - that: flutter_rust_bridge::for_generated::wasm_bindgen::JsValue, -) { - wire_Collection_download_game_impl(port_, that) -} - #[wasm_bindgen] pub fn wire_Collection_game_directory( port_: flutter_rust_bridge::for_generated::MessagePort, @@ -670,19 +662,19 @@ pub fn wire_Collection_get_collection_id( } #[wasm_bindgen] -pub fn wire_Collection_get_loader( +pub fn wire_Collection_launch_game( port_: flutter_rust_bridge::for_generated::MessagePort, that: flutter_rust_bridge::for_generated::wasm_bindgen::JsValue, ) { - wire_Collection_get_loader_impl(port_, that) + wire_Collection_launch_game_impl(port_, that) } #[wasm_bindgen] -pub fn wire_Collection_launch_game( +pub fn wire_Collection_save( port_: flutter_rust_bridge::for_generated::MessagePort, that: flutter_rust_bridge::for_generated::wasm_bindgen::JsValue, ) { - wire_Collection_launch_game_impl(port_, that) + wire_Collection_save_impl(port_, that) } #[wasm_bindgen] @@ -690,6 +682,14 @@ pub fn wire_Collection_scan(port_: flutter_rust_bridge::for_generated::MessagePo wire_Collection_scan_impl(port_) } +#[wasm_bindgen] +pub fn wire_Collection_verify_and_download_game( + port_: flutter_rust_bridge::for_generated::MessagePort, + that: flutter_rust_bridge::for_generated::wasm_bindgen::JsValue, +) { + wire_Collection_verify_and_download_game_impl(port_, that) +} + #[wasm_bindgen] pub fn wire_create_collection( port_: flutter_rust_bridge::for_generated::MessagePort,