From 96cc5257de09682df345e768dc2a91303f9b36c9 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Thu, 3 Nov 2022 21:34:04 +0100 Subject: added update beginnings; init of tests --- src/lib.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 4ad7c39..e059293 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,11 +4,31 @@ pub mod commands; pub mod input; pub mod db; +use std::io::{Error, ErrorKind}; + pub use apis::*; pub use commands::*; -#[derive(Debug)] +#[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> { + match string.as_str() { + "forge" => Ok(Modloader::Forge), + "fabric" => Ok(Modloader::Fabric), + _ => Err(Box::new(Error::new(ErrorKind::InvalidData, "UNKNOWN_MODLOADER"))) + } +} -- cgit v1.2.3