Skip to main content

factorio_ir/
function.rs

1use crate::{block::Block, debug::FunctionDebug, r#type::Type};
2
3#[derive(Debug, Clone, PartialEq, Eq)]
4pub struct Parameter {
5    pub name: String,
6    pub r#type: Type,
7    pub source_type: Option<String>,
8}
9
10/// Metadata from `#[factorio_rs::export]` / `#[factorio_rs::export(interface = "...")]`.
11#[derive(Debug, Clone, PartialEq, Eq)]
12pub struct ExportMeta {
13    /// Override for the Factorio remote interface name (control-stage exports).
14    /// When `None`, the consuming mod's package name is used at emit time.
15    pub interface: Option<String>,
16}
17
18#[derive(Debug, Clone, PartialEq)]
19pub struct Function {
20    pub name: String,
21    pub params: Vec<Parameter>,
22    pub body: Block,
23    pub doc: Option<String>,
24    pub debug: Option<FunctionDebug>,
25    /// Factorio event name when this function is registered with `#[factorio_rs::event(...)]`.
26    pub event: Option<String>,
27    /// Optional event filter table passed to `script.on_event`.
28    pub event_filter: Option<crate::expression::Expression>,
29    /// Present when marked with `#[factorio_rs::export]`.
30    pub export: Option<ExportMeta>,
31}