aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src-tauri/src/core/modpack/formats/mod.rs
diff options
context:
space:
mode:
author苏向夜 <46275354+fu050409@users.noreply.github.com>2026-04-02 11:27:09 +0800
committerGitHub <noreply@github.com>2026-04-02 11:27:09 +0800
commite5f94912615e69c32c353fd6a63790e9b16685e4 (patch)
treedc1a8a0f757e4b4829bbc08c401ac9016f9b52b3 /src-tauri/src/core/modpack/formats/mod.rs
parent0f44b957f0e4bd76146c95ef5c8b75cd61b457c1 (diff)
downloadDropOut-e5f94912615e69c32c353fd6a63790e9b16685e4.tar.gz
DropOut-e5f94912615e69c32c353fd6a63790e9b16685e4.zip
refactor(modpack): split modpack module and extract curseforge api (#127)
Co-authored-by: wsrsq <wsrsq001@163.com> Co-authored-by: 简律纯 <i@jyunko.cn> Co-authored-by: HsiangNianian <44714368+HsiangNianian@users.noreply.github.com>
Diffstat (limited to 'src-tauri/src/core/modpack/formats/mod.rs')
-rw-r--r--src-tauri/src/core/modpack/formats/mod.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src-tauri/src/core/modpack/formats/mod.rs b/src-tauri/src/core/modpack/formats/mod.rs
new file mode 100644
index 0000000..d7fbb50
--- /dev/null
+++ b/src-tauri/src/core/modpack/formats/mod.rs
@@ -0,0 +1,16 @@
+mod curseforge;
+mod modrinth;
+mod multimc;
+
+use super::{archive::Archive, types::ParsedModpack};
+
+type ParserFn = fn(&mut Archive) -> Result<ParsedModpack, String>;
+
+const PARSERS: [ParserFn; 3] = [modrinth::parse, curseforge::parse, multimc::parse];
+
+pub(crate) fn parse(archive: &mut Archive) -> Result<ParsedModpack, String> {
+ PARSERS
+ .iter()
+ .find_map(|parser| parser(archive).ok())
+ .ok_or_else(|| "unsupported modpack".to_string())
+}