From e5f94912615e69c32c353fd6a63790e9b16685e4 Mon Sep 17 00:00:00 2001 From: 苏向夜 <46275354+fu050409@users.noreply.github.com> Date: Thu, 2 Apr 2026 11:27:09 +0800 Subject: refactor(modpack): split modpack module and extract curseforge api (#127) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: wsrsq Co-authored-by: 简律纯 Co-authored-by: HsiangNianian <44714368+HsiangNianian@users.noreply.github.com> --- src-tauri/src/core/modpack/formats/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src-tauri/src/core/modpack/formats/mod.rs (limited to 'src-tauri/src/core/modpack/formats/mod.rs') 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; + +const PARSERS: [ParserFn; 3] = [modrinth::parse, curseforge::parse, multimc::parse]; + +pub(crate) fn parse(archive: &mut Archive) -> Result { + PARSERS + .iter() + .find_map(|parser| parser(archive).ok()) + .ok_or_else(|| "unsupported modpack".to_string()) +} -- cgit v1.2.3-70-g09d2