summaryrefslogtreecommitdiff
path: root/src/data/modloader.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/modloader.rs')
-rw-r--r--src/data/modloader.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/data/modloader.rs b/src/data/modloader.rs
new file mode 100644
index 0000000..050213f
--- /dev/null
+++ b/src/data/modloader.rs
@@ -0,0 +1,39 @@
1use std::fmt::Display;
2
3use serde::{Deserialize, Serialize};
4
5use crate::error::{EType, MLErr, MLE};
6
7#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
8pub enum Modloader {
9 #[serde(rename(serialize = "fabric", deserialize = "fabric"))]
10 Fabric,
11 #[serde(rename(serialize = "forge", deserialize = "forge"))]
12 Forge,
13 #[serde(rename(serialize = "quilt", deserialize = "quilt"))]
14 Quilt,
15}
16
17impl Modloader {
18 /// # Errors
19 pub fn from(string: &str) -> MLE<Modloader> {
20 match string {
21 "forge" => Ok(Modloader::Forge),
22 "fabric" => Ok(Modloader::Fabric),
23 "quilt" => Ok(Modloader::Quilt),
24 _ => {
25 Err(MLErr::new(EType::ArgumentError, "UNKNOWN_MODLOADER"))
26 }
27 }
28 }
29}
30
31impl Display for Modloader {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 match self {
34 Modloader::Fabric => write!(f, "fabric"),
35 Modloader::Forge => write!(f, "forge"),
36 Modloader::Quilt => write!(f, "quilt"),
37 }
38 }
39}