diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -1,36 +1,37 @@ | |||
1 | pub mod apis; | 1 | pub mod apis; |
2 | pub mod config; | ||
3 | pub mod commands; | 2 | pub mod commands; |
4 | pub mod input; | 3 | pub mod config; |
5 | pub mod db; | 4 | pub mod db; |
6 | pub mod error; | 5 | pub mod error; |
7 | pub mod files; | 6 | pub mod files; |
8 | 7 | ||
9 | use std::path::Path; | 8 | use std::{fmt::Display, path::Path}; |
10 | 9 | ||
11 | pub use apis::*; | 10 | pub use apis::*; |
12 | pub use commands::*; | 11 | pub use commands::*; |
13 | use error::{MLE, ErrorType, MLError}; | 12 | use error::{ErrorType, MLError, MLE}; |
14 | 13 | ||
15 | #[derive(Debug, Clone, PartialEq, Eq)] | 14 | #[derive(Debug, Clone, PartialEq, Eq)] |
16 | pub enum Modloader { | 15 | pub enum Modloader { |
17 | Fabric, | 16 | Fabric, |
18 | Forge | 17 | Forge, |
19 | } | 18 | } |
20 | 19 | ||
21 | impl Modloader { | 20 | impl Modloader { |
22 | fn to_string(&self) -> String { | 21 | pub fn from(string: &str) -> MLE<Modloader> { |
23 | match self { | ||
24 | Modloader::Fabric => String::from("fabric"), | ||
25 | Modloader::Forge => String::from("forge"), | ||
26 | } | ||
27 | } | ||
28 | |||
29 | fn from(string: &str) -> MLE<Modloader> { | ||
30 | match string { | 22 | match string { |
31 | "forge" => Ok(Modloader::Forge), | 23 | "forge" => Ok(Modloader::Forge), |
32 | "fabric" => Ok(Modloader::Fabric), | 24 | "fabric" => Ok(Modloader::Fabric), |
33 | _ => Err(MLError::new(ErrorType::ArgumentError, "UNKNOWN_MODLOADER")) | 25 | _ => Err(MLError::new(ErrorType::ArgumentError, "UNKNOWN_MODLOADER")), |
26 | } | ||
27 | } | ||
28 | } | ||
29 | |||
30 | impl Display for Modloader { | ||
31 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
32 | match self { | ||
33 | Modloader::Fabric => write!(f, "fabric"), | ||
34 | Modloader::Forge => write!(f, "forge"), | ||
34 | } | 35 | } |
35 | } | 36 | } |
36 | } | 37 | } |