diff options
Diffstat (limited to 'src-tauri/src/core/modpack/formats/mod.rs')
| -rw-r--r-- | src-tauri/src/core/modpack/formats/mod.rs | 16 |
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()) +} |