diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -4,11 +4,31 @@ pub mod commands; | |||
4 | pub mod input; | 4 | pub mod input; |
5 | pub mod db; | 5 | pub mod db; |
6 | 6 | ||
7 | use std::io::{Error, ErrorKind}; | ||
8 | |||
7 | pub use apis::*; | 9 | pub use apis::*; |
8 | pub use commands::*; | 10 | pub use commands::*; |
9 | 11 | ||
10 | #[derive(Debug)] | 12 | #[derive(Debug, Clone)] |
11 | pub enum Modloader { | 13 | pub enum Modloader { |
12 | Fabric, | 14 | Fabric, |
13 | Forge | 15 | Forge |
14 | } | 16 | } |
17 | |||
18 | impl Modloader { | ||
19 | fn stringify(&self) -> String { | ||
20 | match self { | ||
21 | Modloader::Fabric => String::from("fabric"), | ||
22 | Modloader::Forge => String::from("forge"), | ||
23 | } | ||
24 | } | ||
25 | |||
26 | } | ||
27 | |||
28 | pub fn get_modloader(string: String) -> Result<Modloader, Box<dyn std::error::Error>> { | ||
29 | match string.as_str() { | ||
30 | "forge" => Ok(Modloader::Forge), | ||
31 | "fabric" => Ok(Modloader::Fabric), | ||
32 | _ => Err(Box::new(Error::new(ErrorKind::InvalidData, "UNKNOWN_MODLOADER"))) | ||
33 | } | ||
34 | } | ||