diff options
Diffstat (limited to 'src/data/modloader.rs')
-rw-r--r-- | src/data/modloader.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/data/modloader.rs b/src/data/modloader.rs index 050213f..ef2611b 100644 --- a/src/data/modloader.rs +++ b/src/data/modloader.rs | |||
@@ -2,7 +2,7 @@ use std::fmt::Display; | |||
2 | 2 | ||
3 | use serde::{Deserialize, Serialize}; | 3 | use serde::{Deserialize, Serialize}; |
4 | 4 | ||
5 | use crate::error::{EType, MLErr, MLE}; | 5 | use crate::errors::ConversionError; |
6 | 6 | ||
7 | #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] | 7 | #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] |
8 | pub enum Modloader { | 8 | pub enum Modloader { |
@@ -14,16 +14,14 @@ pub enum Modloader { | |||
14 | Quilt, | 14 | Quilt, |
15 | } | 15 | } |
16 | 16 | ||
17 | impl Modloader { | 17 | impl TryFrom<&str> for Modloader { |
18 | /// # Errors | 18 | type Error = ConversionError; |
19 | pub fn from(string: &str) -> MLE<Modloader> { | 19 | fn try_from(value: &str) -> Result<Self, Self::Error> { |
20 | match string { | 20 | match value { |
21 | "forge" => Ok(Modloader::Forge), | 21 | "forge" => Ok(Modloader::Forge), |
22 | "fabric" => Ok(Modloader::Fabric), | 22 | "fabric" => Ok(Modloader::Fabric), |
23 | "quilt" => Ok(Modloader::Quilt), | 23 | "quilt" => Ok(Modloader::Quilt), |
24 | _ => { | 24 | _ => Err(ConversionError::Modloader(value.to_string())) |
25 | Err(MLErr::new(EType::ArgumentError, "UNKNOWN_MODLOADER")) | ||
26 | } | ||
27 | } | 25 | } |
28 | } | 26 | } |
29 | } | 27 | } |