summaryrefslogtreecommitdiff
path: root/src/lib.rs
blob: e059293562a60d946719ef3dbc190c9f503c2284 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
pub mod apis;
pub mod config;
pub mod commands;
pub mod input;
pub mod db;

use std::io::{Error, ErrorKind};

pub use apis::*;
pub use commands::*;

#[derive(Debug, Clone)]
pub enum Modloader {
    Fabric,
    Forge
}

impl Modloader {
    fn stringify(&self) -> String {
        match self {
            Modloader::Fabric => String::from("fabric"),
            Modloader::Forge => String::from("forge"),
        }
    }

}

pub fn get_modloader(string: String) -> Result<Modloader, Box<dyn std::error::Error>> {
    match string.as_str() {
        "forge" => Ok(Modloader::Forge),
        "fabric" => Ok(Modloader::Fabric),
        _ => Err(Box::new(Error::new(ErrorKind::InvalidData, "UNKNOWN_MODLOADER")))
    }
}