lux_lib/lua_rockspec/build/
rust_mlua.rs

1use std::{collections::HashMap, path::PathBuf};
2
3use mlua::UserData;
4
5#[derive(Debug, PartialEq, Default, Clone)]
6pub struct RustMluaBuildSpec {
7    /// Keys are module names in the format normally used by the `require()` function.
8    /// values are the library names in the target directory.
9    pub modules: HashMap<String, PathBuf>,
10    /// Set if the cargo `target` directory is not in the source root.
11    pub target_path: PathBuf,
12    /// If set to `false` pass `--no-default-features` to cargo.
13    pub default_features: bool,
14    /// Copy additional files to the `lua` directory.
15    /// Keys are the sources, values the destinations (relative to the `lua` directory).
16    pub include: HashMap<PathBuf, PathBuf>,
17    /// Pass additional features
18    pub features: Vec<String>,
19}
20
21impl UserData for RustMluaBuildSpec {
22    fn add_methods<M: mlua::UserDataMethods<Self>>(methods: &mut M) {
23        methods.add_method("modules", |_, this, _: ()| Ok(this.modules.clone()));
24        methods.add_method("target_path", |_, this, _: ()| Ok(this.target_path.clone()));
25        methods.add_method("default_features", |_, this, _: ()| {
26            Ok(this.default_features)
27        });
28        methods.add_method("include", |_, this, _: ()| Ok(this.include.clone()));
29        methods.add_method("features", |_, this, _: ()| Ok(this.features.clone()));
30    }
31}