Closed
Description
This will require implementing a wrapper structure around the lua state. It should be possible to get an instance of the structure from the global state. Also add the call
method, which takes as input a reference to the structure containing the arguments and returns a Result
containing the result of the lua function or an error.
For example:
#[derive(ToLuaTable)]
struct User {
username: String,
email: String,
id: u64,
active: bool,
}
#[derive(FromLuaTable)]
struct CreateUserResult {
ok: bool,
id: u64,
}
...
let lua = Lua::global()
let result: CreateUserResult = lua.call("some_module.create_user", &user)?;
if result.ok {
...
}
-- some_module.lua
function create_user(username, email, id, active)
...
return true, id
end