diff options
| author | 2026-04-02 11:27:09 +0800 | |
|---|---|---|
| committer | 2026-04-02 11:27:09 +0800 | |
| commit | e5f94912615e69c32c353fd6a63790e9b16685e4 (patch) | |
| tree | dc1a8a0f757e4b4829bbc08c401ac9016f9b52b3 /src-tauri/src/core/modpack/parser.rs | |
| parent | 0f44b957f0e4bd76146c95ef5c8b75cd61b457c1 (diff) | |
| download | DropOut-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/parser.rs')
| -rw-r--r-- | src-tauri/src/core/modpack/parser.rs | 23 |
1 files changed, 23 insertions, 0 deletions
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<ParsedModpack, String>; +} + +#[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<ParsedModpack, String> { + let mut archive = archive::open(path)?; + Ok(formats::parse(&mut archive).unwrap_or_else(|_| ParsedModpack::unknown(path))) + } +} |