summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/lib.rs b/src/lib.rs
index eb845d8..43f0fe7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,36 +1,37 @@
1pub mod apis; 1pub mod apis;
2pub mod config;
3pub mod commands; 2pub mod commands;
4pub mod input; 3pub mod config;
5pub mod db; 4pub mod db;
6pub mod error; 5pub mod error;
7pub mod files; 6pub mod files;
8 7
9use std::path::Path; 8use std::{fmt::Display, path::Path};
10 9
11pub use apis::*; 10pub use apis::*;
12pub use commands::*; 11pub use commands::*;
13use error::{MLE, ErrorType, MLError}; 12use error::{ErrorType, MLError, MLE};
14 13
15#[derive(Debug, Clone, PartialEq, Eq)] 14#[derive(Debug, Clone, PartialEq, Eq)]
16pub enum Modloader { 15pub enum Modloader {
17 Fabric, 16 Fabric,
18 Forge 17 Forge,
19} 18}
20 19
21impl Modloader { 20impl 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
30impl 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}