inf2ron 0.1.0

Parse Stranded II .inf definition files (items, objects, units, buildings, combinations) and output RON format
Documentation
// inf2ron – parse Stranded II .inf definition files to RON
// Copyright (C) 2025  inf2ron contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

//! Data types produced when parsing .inf files.

use std::collections::HashMap;

use serde::{Deserialize, Serialize};

/// A single entity record from an .inf file.
/// For example, one item definition from items_edible.inf.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InfEntry {
    /// Source line number (not serialized)
    #[serde(skip)]
    pub line: usize,
    /// All key=value fields (including multivalue keys)
    pub fields: HashMap<String, Vec<String>>,
    /// Content of `script=start` ... `script=end` block (if any)
    /// Raw .s2s source.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub script: Option<String>,
    /// Content of `description=start` ... `description=end` block (if any)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// Content of `combi=start` ... `combi=end` block (crafting recipes)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub combi: Option<CombiBlock>,
}

/// A crafting recipe block (`combi=start` / `combi=end`)
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CombiBlock {
    pub fields: HashMap<String, Vec<String>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub script: Option<String>,
}

/// Result of parsing a single .inf file
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InfFile {
    pub path: String,
    pub entries: Vec<InfEntry>,
}