From 11e64fc7560de3cd0def718edf68c31e3dc8be72 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 4 Sep 2024 15:08:55 +0200 Subject: move stuff around, remove lib.rs for overview --- src/data/modloader.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/data/modloader.rs (limited to 'src/data/modloader.rs') 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 @@ +use std::fmt::Display; + +use serde::{Deserialize, Serialize}; + +use crate::error::{EType, MLErr, MLE}; + +#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] +pub enum Modloader { + #[serde(rename(serialize = "fabric", deserialize = "fabric"))] + Fabric, + #[serde(rename(serialize = "forge", deserialize = "forge"))] + Forge, + #[serde(rename(serialize = "quilt", deserialize = "quilt"))] + Quilt, +} + +impl Modloader { + /// # Errors + pub fn from(string: &str) -> MLE { + match string { + "forge" => Ok(Modloader::Forge), + "fabric" => Ok(Modloader::Fabric), + "quilt" => Ok(Modloader::Quilt), + _ => { + Err(MLErr::new(EType::ArgumentError, "UNKNOWN_MODLOADER")) + } + } + } +} + +impl Display for Modloader { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Modloader::Fabric => write!(f, "fabric"), + Modloader::Forge => write!(f, "forge"), + Modloader::Quilt => write!(f, "quilt"), + } + } +} -- cgit v1.2.3