You've already forked AstralRinth
forked from didirus/AstralRinth
Rustic cleanups, dedups and making the code less hard to read in general (#251)
* typos :help_me: * (part 1/?) massive cleanup to make the code more Rust-ic and cut down heap allocations. * (part 2/?) massive cleanup to make the code more Rust-ic and cut down heap allocations. * (part 3/?) cut down some pretty major heap allocations here - more Bytes and BytesMuts, less Vec<u8>s also I don't really understand why you need to `to_vec` when you don't really use it again afterwards * (part 4/?) deduplicate error handling in backblaze logic * (part 5/?) fixes, cleanups, refactors, and reformatting * (part 6/?) cleanups and refactors * remove loads of `as_str` in types that already are `Display` * Revert "remove loads of `as_str` in types that already are `Display`" This reverts commit 4f974310cfb167ceba03001d81388db4f0fbb509. * reformat and move routes util to the util module * use streams * Run prepare + formatting issues Co-authored-by: Jai A <jaiagr+gpg@pm.me> Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
@@ -18,9 +18,9 @@ pub enum ValidationError {
|
||||
#[error("IO Error: {0}")]
|
||||
IoError(#[from] std::io::Error),
|
||||
#[error("Error while validating JSON: {0}")]
|
||||
SerDeError(#[from] serde_json::Error),
|
||||
SerdeError(#[from] serde_json::Error),
|
||||
#[error("Invalid Input: {0}")]
|
||||
InvalidInputError(String),
|
||||
InvalidInputError(std::borrow::Cow<'static, str>),
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
@@ -28,7 +28,7 @@ pub enum ValidationResult {
|
||||
/// File should be marked as primary
|
||||
Pass,
|
||||
/// File should not be marked primary, the reason for which is inside the String
|
||||
Warning(String),
|
||||
Warning(&'static str),
|
||||
}
|
||||
|
||||
pub enum SupportedGameVersions {
|
||||
@@ -39,9 +39,9 @@ pub enum SupportedGameVersions {
|
||||
}
|
||||
|
||||
pub trait Validator: Sync {
|
||||
fn get_file_extensions<'a>(&self) -> &'a [&'a str];
|
||||
fn get_project_types<'a>(&self) -> &'a [&'a str];
|
||||
fn get_supported_loaders<'a>(&self) -> &'a [&'a str];
|
||||
fn get_file_extensions(&self) -> &[&str];
|
||||
fn get_project_types(&self) -> &[&str];
|
||||
fn get_supported_loaders(&self) -> &[&str];
|
||||
fn get_supported_game_versions(&self) -> SupportedGameVersions;
|
||||
fn validate(
|
||||
&self,
|
||||
@@ -50,10 +50,10 @@ pub trait Validator: Sync {
|
||||
}
|
||||
|
||||
static VALIDATORS: [&dyn Validator; 4] = [
|
||||
&PackValidator {},
|
||||
&FabricValidator {},
|
||||
&ForgeValidator {},
|
||||
&LegacyForgeValidator {},
|
||||
&PackValidator,
|
||||
&FabricValidator,
|
||||
&ForgeValidator,
|
||||
&LegacyForgeValidator,
|
||||
];
|
||||
|
||||
/// The return value is whether this file should be marked as primary or not, based on the analysis of the file
|
||||
@@ -89,10 +89,13 @@ pub fn validate_file(
|
||||
}
|
||||
|
||||
if visited {
|
||||
Err(ValidationError::InvalidInputError(format!(
|
||||
"File extension {} is invalid for input file",
|
||||
file_extension
|
||||
)))
|
||||
Err(ValidationError::InvalidInputError(
|
||||
format!(
|
||||
"File extension {} is invalid for input file",
|
||||
file_extension
|
||||
)
|
||||
.into(),
|
||||
))
|
||||
} else {
|
||||
Ok(ValidationResult::Pass)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user