blob: 397d69624df7be27daf854e1d8f79400d8be95ae (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)))
}
}
|