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/parser.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src-tauri/src/core/modpack/parser.rs (limited to 'src-tauri/src/core/modpack/parser.rs') diff --git a/src-tauri/src/core/modpack/parser.rs b/src-tauri/src/core/modpack/parser.rs new file mode 100644 index 0000000..397d696 --- /dev/null +++ b/src-tauri/src/core/modpack/parser.rs @@ -0,0 +1,23 @@ +use std::path::Path; + +use super::{archive, formats, types::ParsedModpack}; + +pub(crate) trait ModpackParser: Send + Sync { + fn parse(&self, path: &Path) -> Result; +} + +#[derive(Debug, Default, Clone, Copy)] +pub(crate) struct ZipModpackParser; + +impl ZipModpackParser { + pub(crate) fn new() -> Self { + Self + } +} + +impl ModpackParser for ZipModpackParser { + fn parse(&self, path: &Path) -> Result { + let mut archive = archive::open(path)?; + Ok(formats::parse(&mut archive).unwrap_or_else(|_| ParsedModpack::unknown(path))) + } +} -- cgit v1.2.3-70-g09d2