Skip to main content

modde_games/cyberpunk/
manifest.rs

1//! Types for parsing the `REDmod` `info.json` mod manifest.
2
3use serde::Deserialize;
4
5/// `REDmod` mod manifest (`info.json`).
6#[derive(Debug, Clone, Deserialize)]
7pub struct RedModManifest {
8    pub name: String,
9    pub version: Option<String>,
10    #[serde(default)]
11    pub custom_sounds: Vec<CustomSound>,
12    #[serde(default)]
13    pub scripts: Vec<ScriptEntry>,
14}
15
16/// A custom sound entry declared in a `REDmod` manifest.
17#[derive(Debug, Clone, Deserialize)]
18pub struct CustomSound {
19    pub name: String,
20    #[serde(rename = "type")]
21    pub sound_type: Option<String>,
22    pub file: String,
23}
24
25/// A script entry declared in a `REDmod` manifest.
26#[derive(Debug, Clone, Deserialize)]
27pub struct ScriptEntry {
28    pub name: String,
29    pub path: Option<String>,
30}
31
32impl RedModManifest {
33    /// Parse a `REDmod` `info.json` file.
34    pub fn parse(json: &str) -> anyhow::Result<Self> {
35        Ok(serde_json::from_str(json)?)
36    }
37}