lib.rs

 1use std::collections::{HashMap, HashSet};
 2
 3use mlua::{Error, FromLua, Function, Lua, ToLua, UserData, Value};
 4
 5pub mod runtime;
 6pub use runtime::*;
 7
 8impl Runtime for Lua {
 9    type Module = String;
10
11    fn init(module: Self::Module) -> Option<Self> {
12        let lua = Lua::new();
13        lua.load(&module).exec().ok()?;
14        return Some(lua);
15    }
16
17    fn interface(&self) -> Interface {
18        let mut globals = HashSet::new();
19        for pair in self.globals().pairs::<String, Value>() {
20            if let Ok((k, _)) = pair {
21                globals.insert(k);
22            }
23        }
24
25        globals
26    }
27}