factorio-prototypes-json 0.1.0

Rust types that parse Factorio's Prototype JSON Format.
Documentation
//! A [`Prototype`] is a template for a component in the Factorio game engine.
//! They define parameters which the engine uses to create predefined behavior.
//!
//! Equivalent to the [prototypes](https://lua-api.factorio.com/latest/prototypes.html) page.

use serde::{Deserialize, Serialize};
use serde_json::Number;

use super::basic_members::BasicMembers;
use super::custom_properties::CustomProperties;
use super::property::Property;

/// Prototypes are templates for components in the game engine. They define parameters which the engine uses to create predefined behavior.
#[derive(Serialize, Deserialize, Debug)]
pub struct Prototype {
    /// The basic fields of the type.
    #[serde(flatten)]
    pub basic: BasicMembers,

    /// The list of game expansions needed to use this prototype.
    ///
    /// If not present, no restrictions apply.
    ///
    /// Possible values: `"space_age"`
    pub visibility: Option<Vec<String>>,

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

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

    /// The type name of the prototype, like `"boiler"`. [`None`] for abstract prototypes.
    pub typename: Option<String>,

    /// The maximum number of instances of this prototype tnat can be created, if any.
    pub instance_limit: Option<Number>,

    /// Whether the prototype is deprecated and shouldn't be used anymore.
    pub deprecated: bool,

    /// The list of properties that the prototype has. May be empty.
    pub properties: Vec<Property>,

    /// A special set of properties that the user can add an arbitrary number of.
    ///
    /// Specifies the type of the key and value of the custom property.
    pub custom_properties: Option<CustomProperties>,
}