use mlua::prelude::*; pub mod datatypes; pub mod document; pub mod instance; use datatypes::types::*; use datatypes::DatatypeTable; fn make_dt(lua: &Lua, f: F) -> LuaResult where F: Fn(&Lua, &LuaTable) -> LuaResult<()>, { let tab = lua.create_table()?; f(lua, &tab)?; tab.set_readonly(true); Ok(tab) } pub fn module(lua: &Lua) -> LuaResult { let datatypes = vec![("Vector3", make_dt(lua, Vector3::make_dt_table)?)]; let exports = lua.create_table()?; for (name, tab) in datatypes { exports.set(name, tab)?; } Ok(exports) }