modde-games 0.2.1

Game plugin implementations for modde
Documentation
//! Types for parsing the `REDmod` `info.json` mod manifest.

use serde::Deserialize;

/// `REDmod` mod manifest (`info.json`).
#[derive(Debug, Clone, Deserialize)]
pub struct RedModManifest {
    pub name: String,
    pub version: Option<String>,
    #[serde(default)]
    pub custom_sounds: Vec<CustomSound>,
    #[serde(default)]
    pub scripts: Vec<ScriptEntry>,
}

/// A custom sound entry declared in a `REDmod` manifest.
#[derive(Debug, Clone, Deserialize)]
pub struct CustomSound {
    pub name: String,
    #[serde(rename = "type")]
    pub sound_type: Option<String>,
    pub file: String,
}

/// A script entry declared in a `REDmod` manifest.
#[derive(Debug, Clone, Deserialize)]
pub struct ScriptEntry {
    pub name: String,
    pub path: Option<String>,
}

impl RedModManifest {
    /// Parse a `REDmod` `info.json` file.
    pub fn parse(json: &str) -> anyhow::Result<Self> {
        Ok(serde_json::from_str(json)?)
    }
}