-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
221 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,32 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn it_works() { | ||
let result = 2 + 2; | ||
assert_eq!(result, 4); | ||
} | ||
//! # Dotium | ||
//! | ||
//! Dotium is the uniform object provider for Minecraft Mod hosting platforms, | ||
//! who get traits in Libraries like Ferinth and Furse to then be used platform independedly in Libium. | ||
//! | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub mod project; | ||
pub mod request; | ||
pub mod version; | ||
|
||
pub struct Platform { | ||
/// The name of the platform | ||
name: String, | ||
/// The two-letter nick name of the Platform | ||
short_name: String, | ||
/// Logo of the platform | ||
logo: request::Asset, | ||
} | ||
|
||
pub trait PlatformTrait { | ||
fn get_project(id: String) -> Result<project::Project>; | ||
|
||
// TODO Search | ||
fn search() -> Result<Vec<project::Project>>; | ||
} | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error {} | ||
|
||
pub(crate) type Result<T> = std::result::Result<T, Error>; | ||
pub type Datetime = chrono::DateTime<chrono::Utc>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
use crate::version::Version; | ||
|
||
use super::*; | ||
|
||
#[derive(Deserialize, Serialize, Debug, Clone)] | ||
pub struct Project { | ||
/// The project's ID | ||
pub id: String, | ||
/// The project's slug | ||
pub slug: String, | ||
/// The project's type | ||
pub project_type: Type, | ||
/// The project's Name | ||
pub name: String, | ||
/// The Description of the project | ||
pub description: String, | ||
/// Links to external project pages | ||
pub links: Links, | ||
/// Requirements on server and/or client | ||
pub requirements: Requirement, | ||
/// The project's categories | ||
// TODO: Icons, not only the names | ||
pub categories: Vec<String>, | ||
/// Download count of the project | ||
pub downloads: i64, | ||
/// The count of the current project followers | ||
/// CurseForge: Thumbs up count | ||
pub followers: i32, | ||
/// Icon of the project | ||
pub icon: request::Asset, | ||
/// The current status of approval for the mod | ||
pub status: Status, | ||
/// The date when the project was published | ||
/// Curseforge: Date released | ||
pub published: Datetime, | ||
/// The date the project was last updated | ||
pub updated: Datetime, | ||
/// The date the project was created | ||
pub created: Datetime, | ||
/// A mod's pictures / gallery | ||
pub gallery: Vec<request::Asset>, | ||
/// If the project allows for distribution | ||
/// Modrinth: Depends on license | ||
pub allows_distribution: bool, | ||
/// The project's authors | ||
pub authors: Vec<Author>, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)] | ||
pub enum Type { | ||
Mod, | ||
Modpack, | ||
Ressourcepack, | ||
This comment has been minimized.
Sorry, something went wrong. |
||
Shader, | ||
Addon, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Eskaan
Author
Contributor
|
||
Plugin | ||
} | ||
|
||
#[derive(Deserialize, Serialize, Debug, Clone)] | ||
pub struct Links { | ||
///A link to the mod's GitHub page | ||
github: Option<String>, | ||
///A link to the mod's issue tracker | ||
issues: Option<String>, | ||
///A link to the mod's wiki | ||
wiki: Option<String>, | ||
///A link to the mod's discord | ||
discord: Option<String>, | ||
///An array of to the mod's donation platforms | ||
donations: Option<Vec<DonationLink>>, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, Debug, Clone)] | ||
pub struct DonationLink { | ||
///The platform ID | ||
id: String, | ||
///The platform name | ||
platform: String, | ||
///The link to the donations page of the platform | ||
url: String, | ||
} | ||
|
||
/// Requirements of a projects, for server and Client | ||
/// Modrinth only, CF will show up as Unkown | ||
#[derive(Deserialize, Serialize, Debug, Clone)] | ||
pub struct ProjectRequirements { | ||
server: Requirement, | ||
client: Requirement, | ||
} | ||
|
||
/// Requirement status | ||
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)] | ||
pub enum Requirement { | ||
Required, | ||
Optional, | ||
Unsupported, | ||
Unkown, | ||
} | ||
|
||
/// Status of a Project | ||
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)] | ||
pub enum Status { | ||
/// Modrinth: Draft | ||
New, | ||
/// Modrinth only | ||
Unlisted, | ||
/// CurseForge only | ||
ChangesRequired, | ||
/// CurseForge only | ||
UnderSoftReview, | ||
/// Modrinth: Approved | ||
Approved, | ||
/// Modrinth: Rejected | ||
Rejected, | ||
/// CurseForge only | ||
ChangesMade, | ||
/// CurseForge only | ||
Inactive, | ||
/// Modrinth: Archived | ||
Abandoned, | ||
/// Modrinth: Unkown | ||
Deleted, | ||
/// Modrinth: Processing | ||
UnderReview, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, Debug, Clone)] | ||
pub struct Author { | ||
/// The unique username of the user | ||
username: String, | ||
/// The display name of the user | ||
name: String, | ||
// The ID of the user | ||
id: String, | ||
/// The Avatar URL of the user | ||
avatar_url: Option<String> | ||
} | ||
|
||
pub trait ProjectTrait { | ||
fn get_body(&self) -> Result<String>; | ||
|
||
fn get_versions(&self) -> Result<Vec<Version>>; | ||
|
||
fn get_version(&self, id: String) -> Result<Version>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use super::*; | ||
|
||
#[derive(Deserialize, Serialize, Debug, Clone)] | ||
pub struct Asset { | ||
/// The request URL | ||
url: String, | ||
/// Name of the asset | ||
name: Option<String>, | ||
/// Description of the asset | ||
description: Option<String>, | ||
/// Headers to send with the request | ||
headers: Option<String>, | ||
/// Request type | ||
request_type: RequestType, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)] | ||
pub enum RequestType { | ||
GET, | ||
POST, | ||
PATCH, | ||
DELETE, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use super::*; | ||
|
||
#[derive(Deserialize, Serialize, Debug, Clone)] | ||
pub struct Version { | ||
/// The ID of the version | ||
id: String, | ||
|
||
/// Dependencies on other projects | ||
pub dependencies: Vec<ProjectDependency>, | ||
} | ||
|
||
/// Dependency on a Project's version | ||
#[derive(Deserialize, Serialize, Debug, Clone)] | ||
pub struct ProjectDependency { | ||
//The ID of the project to depend on | ||
project_id: String, | ||
//The version of the project it depends on | ||
version: Version, | ||
} |
You misspelled this