#[derive(Debug, Clone)]
pub enum ModRequest {
Modrinth {
id_or_slug: String,
version: Option<String>,
},
CurseForge {
mod_id: u32,
file_id: Option<u32>,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ModSource {
Modrinth,
CurseForge,
}
impl ModSource {
pub fn as_str(self) -> &'static str {
match self {
ModSource::Modrinth => "modrinth",
ModSource::CurseForge => "curseforge",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ModKey {
pub source: ModSource,
pub id: String,
}
impl ModKey {
pub fn modrinth(id: impl Into<String>) -> Self {
Self { source: ModSource::Modrinth, id: id.into() }
}
pub fn curseforge(mod_id: u32) -> Self {
Self { source: ModSource::CurseForge, id: mod_id.to_string() }
}
}
impl From<&ModRequest> for ModKey {
fn from(req: &ModRequest) -> Self {
match req {
ModRequest::Modrinth { id_or_slug, .. } => ModKey::modrinth(id_or_slug.clone()),
ModRequest::CurseForge { mod_id, .. } => ModKey::curseforge(*mod_id),
}
}
}