summaryrefslogtreecommitdiff
path: root/src/data/modloader.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2024-09-04 15:08:55 +0200
committerfxqnlr <[email protected]>2024-09-04 15:08:55 +0200
commit11e64fc7560de3cd0def718edf68c31e3dc8be72 (patch)
treef14ad1eb3d349e1f95e4d69c251e79ac85786a64 /src/data/modloader.rs
parent7a85cf311c85ab45c75098dae58b5ebf5fef60bc (diff)
downloadmodlist-11e64fc7560de3cd0def718edf68c31e3dc8be72.tar
modlist-11e64fc7560de3cd0def718edf68c31e3dc8be72.tar.gz
modlist-11e64fc7560de3cd0def718edf68c31e3dc8be72.zip
move stuff around, remove lib.rs for overview
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}