You've already forked AstralRinth
forked from didirus/AstralRinth
Mod Creation (#34)
* Inital creation stuff * File Reader * Upload bodies * Major rework: * Finish Multiple Files * Proper Error Handling * Switch to database models * Run formatter * Make dependencies dependent on Versions over mods * Fixes * Fix clippy * Run lint one last time * Update src/models/mods.rs Co-authored-by: AppleTheGolden <scotsbox@protonmail.com> Co-authored-by: AppleTheGolden <scotsbox@protonmail.com>
This commit is contained in:
@@ -84,12 +84,27 @@ macro_rules! from_base62id {
|
||||
};
|
||||
}
|
||||
|
||||
from_base62id! {
|
||||
ModId, ModId;
|
||||
UserId, UserId;
|
||||
VersionId, VersionId;
|
||||
TeamId, TeamId;
|
||||
macro_rules! impl_base62_display {
|
||||
($struct:ty) => {
|
||||
impl std::fmt::Display for $struct {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(&base62_impl::to_base62(self.0))
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
impl_base62_display!(Base62Id);
|
||||
|
||||
macro_rules! base62_id_impl {
|
||||
($struct:ty, $cons:expr) => {
|
||||
from_base62id!($struct, $cons;);
|
||||
impl_base62_display!($struct);
|
||||
}
|
||||
}
|
||||
base62_id_impl!(ModId, ModId);
|
||||
base62_id_impl!(UserId, UserId);
|
||||
base62_id_impl!(VersionId, VersionId);
|
||||
base62_id_impl!(TeamId, TeamId);
|
||||
|
||||
pub mod base62_impl {
|
||||
use serde::de::{self, Deserializer, Visitor};
|
||||
|
||||
@@ -24,11 +24,12 @@ pub struct Mod {
|
||||
// unnecessary info
|
||||
/// The team of people that has ownership of this mod.
|
||||
pub team: Team,
|
||||
|
||||
/// The title or name of the mod.
|
||||
pub title: String,
|
||||
/// A short description of the mod.
|
||||
pub description: String,
|
||||
/// The link to the long description of the mod.
|
||||
pub body_url: String,
|
||||
/// The date at which the mod was first published.
|
||||
pub published: DateTime<Utc>,
|
||||
|
||||
@@ -38,10 +39,8 @@ pub struct Mod {
|
||||
pub categories: Vec<String>,
|
||||
/// A list of ids for versions of the mod.
|
||||
pub versions: Vec<VersionId>,
|
||||
|
||||
/// The latest version of the mod.
|
||||
pub latest_version: Version,
|
||||
|
||||
///The URL of the icon of the mod
|
||||
pub icon_url: Option<String>,
|
||||
/// An optional link to where to submit bugs or issues with the mod.
|
||||
pub issues_url: Option<String>,
|
||||
/// An optional link to the source code for the mod.
|
||||
@@ -60,6 +59,8 @@ pub struct Version {
|
||||
|
||||
/// The name of this version
|
||||
pub name: String,
|
||||
/// The version number. Ideally will follow semantic versioning
|
||||
pub version_number: String,
|
||||
/// A link to the changelog for this version of the mod.
|
||||
pub changelog_url: Option<String>,
|
||||
/// The date that this version was published.
|
||||
@@ -72,9 +73,11 @@ 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<ModId>,
|
||||
pub dependencies: Vec<VersionId>,
|
||||
/// 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
|
||||
pub loaders: Vec<ModLoader>,
|
||||
}
|
||||
|
||||
/// A single mod file, with a url for the file and the file's hash
|
||||
@@ -96,18 +99,34 @@ pub struct FileHash {
|
||||
pub hash: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub enum VersionType {
|
||||
Release,
|
||||
Beta,
|
||||
Alpha,
|
||||
}
|
||||
|
||||
impl ToString for VersionType {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
VersionType::Release => "release",
|
||||
VersionType::Beta => "beta",
|
||||
VersionType::Alpha => "alpha",
|
||||
}
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// A specific version of Minecraft
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[serde(transparent)]
|
||||
pub struct GameVersion(pub String);
|
||||
|
||||
/// A mod loader
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[serde(transparent)]
|
||||
pub struct ModLoader(pub String);
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct SearchRequest {
|
||||
pub query: Option<String>,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use super::ids::Base62Id;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
//TODO Implement Item for teams
|
||||
/// The ID of a specific user, encoded as base62 for usage in the API
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(from = "Base62Id")]
|
||||
@@ -24,10 +25,12 @@ pub struct Team {
|
||||
}
|
||||
|
||||
/// A member of a team
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct TeamMember {
|
||||
/// The ID of the user associated with the member
|
||||
pub user_id: UserId,
|
||||
/// The name of the user
|
||||
pub name: String,
|
||||
///The role of the use in the team
|
||||
pub role: String,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user