diff options
author | fxqnlr <[email protected]> | 2022-11-03 21:34:04 +0100 |
---|---|---|
committer | fxqnlr <[email protected]> | 2022-11-03 21:34:04 +0100 |
commit | 96cc5257de09682df345e768dc2a91303f9b36c9 (patch) | |
tree | f505d14c581e2bef4cfe222bd1069661bedd22e0 /src/lib.rs | |
parent | b125dfd03084fff47ab8e90d002c6699b762d998 (diff) | |
download | modlist-96cc5257de09682df345e768dc2a91303f9b36c9.tar modlist-96cc5257de09682df345e768dc2a91303f9b36c9.tar.gz modlist-96cc5257de09682df345e768dc2a91303f9b36c9.zip |
added update beginnings; init of tests
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 | } | ||