lib.rs

 1use mlua::{Error, FromLua, Lua, ToLua, UserData};
 2
 3pub mod runtime;
 4pub use runtime::*;
 5
 6impl Runtime for Lua {
 7    type Module = String;
 8    // type Error = Error;
 9    type Interface = LuaInterface;
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) -> Self::Interface {
18        todo!()
19    }
20
21    fn val<'lua, K: ToLua<'lua>, V: FromLua<'lua>>(&'lua self, key: K) -> Option<V> {
22        self.globals().get(key).ok()
23    }
24}
25
26pub struct LuaInterface {
27    funs: Vec<String>,
28    vals: Vec<String>,
29}
30
31impl Interface for LuaInterface {
32    type Handle = String;
33
34    fn handles(&self) -> &[Self::Handle] {
35        todo!()
36    }
37}