mirror of
https://github.com/modrinth/code.git
synced 2026-08-26 01:26:23 +00:00
36 lines
877 B
Rust
36 lines
877 B
Rust
use crate::validate::{
|
|
SupportedGameVersions, ValidationError, ValidationResult,
|
|
validate_pack_formats,
|
|
};
|
|
use std::io::Cursor;
|
|
use zip::ZipArchive;
|
|
|
|
pub struct FabricValidator;
|
|
|
|
impl super::Validator for FabricValidator {
|
|
fn get_file_extensions(&self) -> &[&str] {
|
|
&["jar"]
|
|
}
|
|
|
|
fn get_supported_loaders(&self) -> &[&str] {
|
|
&["fabric"]
|
|
}
|
|
|
|
fn get_supported_game_versions(&self) -> SupportedGameVersions {
|
|
SupportedGameVersions::All
|
|
}
|
|
|
|
fn validate(
|
|
&self,
|
|
archive: &mut ZipArchive<Cursor<bytes::Bytes>>,
|
|
) -> Result<ValidationResult, ValidationError> {
|
|
if archive.by_name("fabric.mod.json").is_err() {
|
|
return Ok(ValidationResult::Warning(
|
|
"No fabric.mod.json present for Fabric file.",
|
|
));
|
|
}
|
|
|
|
Ok(validate_pack_formats(archive))
|
|
}
|
|
}
|