summaryrefslogtreecommitdiff
path: root/src/lib.rs
blob: 0bf30764d2397b23d193902fe4cd74bdba2af78b (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
35
36
37
38
pub mod apis;
pub mod commands;
pub mod config;
pub mod db;
pub mod error;
pub mod files;
pub mod cache;

use std::fmt::Display;

pub use apis::*;
pub use commands::*;
use error::{ErrorType, MLError, MLE};

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

impl Modloader {
    pub fn from(string: &str) -> MLE<Modloader> {
        match string {
            "forge" => Ok(Modloader::Forge),
            "fabric" => Ok(Modloader::Fabric),
            _ => Err(MLError::new(ErrorType::ArgumentError, "UNKNOWN_MODLOADER")),
        }
    }
}

impl Display for Modloader {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Modloader::Fabric => write!(f, "fabric"),
            Modloader::Forge => write!(f, "forge"),
        }
    }
}