factorio-prototypes-json 0.1.0

Rust types that parse Factorio's Prototype JSON Format.
Documentation
//! A [`Concept`] is a type that the format uses and are commonly used as parts of a prototype.
//!
//! It is equivalent to the [types](https://lua-api.factorio.com/latest/types.html) page in the documentation.

use serde::{Deserialize, Serialize};

use super::basic_members::BasicMembers;
use super::property::Property;
use super::types::Type;

/// A [`Concept`] is a type that the format uses and are commonly used as parts of a prototype.
///
/// It is equivalent to the [types](https://lua-api.factorio.com/latest/types.html) page in the documentation.
#[derive(Serialize, Deserialize, Debug)]
pub struct Concept {
    /// The basic fields of the type.
    #[serde(flatten)]
    pub basic: BasicMembers,

    /// The name of the type's parent, if any.
    pub parent: Option<String>,

    /// Whether the type is abstract, and thus can't be created directly.
    pub r#abstract: Option<bool>,

    /// Whether the type is inlined inside another property's description.
    pub inline: bool,

    /// The type of the type/concept.
    ///
    /// Either a propert [`Type`], or the string `"builtin"`, indicating a fundamental type like `string` or `number`.
    ///
    /// TODO: If this is [`Type::Simple`]`, constrain it to `builtin`.
    pub r#type: Type,

    /// The list of properties that the type has, if its type includes a struct.
    pub properties: Option<Vec<Property>>,
}