ttmp-rs/src/model/manifest_kind.rs

30 lines
674 B
Rust
Raw Normal View History

2022-11-02 20:46:48 +00:00
use serde::{Deserialize, Serialize};
2022-11-02 19:43:25 +00:00
use crate::model::{ModPack, SimpleMod};
2022-11-02 20:46:48 +00:00
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
2022-11-02 19:43:25 +00:00
pub enum ManifestKind {
V1(Vec<SimpleMod>),
V2(ModPack),
}
impl ManifestKind {
pub fn simple_mods_list(&self) -> &[SimpleMod] {
match self {
Self::V1(mods) => mods,
Self::V2(pack) => match &pack.simple_mods_list {
Some(list) => list,
None => &[],
},
}
}
2022-11-02 20:37:44 +00:00
pub fn into_mod_pack(self) -> ModPack {
match self {
Self::V1(mods) => mods.into(),
Self::V2(pack) => pack,
}
}
2022-11-02 19:43:25 +00:00
}