You've already forked AstralRinth
forked from didirus/AstralRinth
Dependencies, fix panic on version get, Filtered Versions route (#153)
This commit is contained in:
@@ -208,7 +208,7 @@ pub struct Version {
|
||||
/// A list of files available for download for this version.
|
||||
pub files: Vec<VersionFile>,
|
||||
/// A list of mods that this version depends on.
|
||||
pub dependencies: Vec<VersionId>,
|
||||
pub dependencies: Vec<Dependency>,
|
||||
/// A list of versions of Minecraft that this version of the mod supports.
|
||||
pub game_versions: Vec<GameVersion>,
|
||||
/// The loaders that this version works on
|
||||
@@ -229,6 +229,16 @@ pub struct VersionFile {
|
||||
pub primary: bool,
|
||||
}
|
||||
|
||||
/// A dependency which describes what versions are required, break support, or are optional to the
|
||||
/// version's functionality
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct Dependency {
|
||||
/// The filename of the file.
|
||||
pub version_id: VersionId,
|
||||
/// Whether the file is the primary file of a version
|
||||
pub dependency_type: DependencyType,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum VersionType {
|
||||
@@ -258,6 +268,44 @@ impl VersionType {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum DependencyType {
|
||||
Required,
|
||||
Optional,
|
||||
Incompatible,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for DependencyType {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
DependencyType::Required => write!(fmt, "required"),
|
||||
DependencyType::Optional => write!(fmt, "optional"),
|
||||
DependencyType::Incompatible => write!(fmt, "incompatible"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DependencyType {
|
||||
// These are constant, so this can remove unneccessary allocations (`to_string`)
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
DependencyType::Required => "required",
|
||||
DependencyType::Optional => "optional",
|
||||
DependencyType::Incompatible => "incompatible",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_str(string: &str) -> DependencyType {
|
||||
match string {
|
||||
"required" => DependencyType::Required,
|
||||
"optional" => DependencyType::Optional,
|
||||
"incompatible" => DependencyType::Incompatible,
|
||||
_ => DependencyType::Required,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A specific version of Minecraft
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[serde(transparent)]
|
||||
|
||||
Reference in New Issue
Block a user