Expand description
mlua-style Lua facade (B12, Phase 2 P2-D).
A thin wrapper around luna_core::vm::Vm that exposes the same
API in a shape familiar to embedders coming from rlua / mlua:
use luna_jit::Lua;
let mut lua = Lua::new();
lua.open_base();
lua.open_math();
let r: i64 = lua.eval("return 1 + 2").unwrap();
assert_eq!(r, 3);
let add = lua.create_function(|a: i64, b: i64| -> i64 { a + b });
lua.set_global("add", add).unwrap();
let r: i64 = lua.eval("return add(40, 2)").unwrap();
assert_eq!(r, 42);§Handles
LuaFunction / LuaTable / LuaRoot are Copy wrappers
around a HostRootTicket returned by Vm::pin_host. They
keep their referenced Gc<T> alive across calls (so a LuaTable
survives a GC cycle even when no Lua-side reference exists).
v1.3 Phase SR added slot recycling — a single handle can be
released via Lua::unpin; the whole batch via
Lua::unpin_all. Both operations bump the slot’s generation,
invalidating any further use of LuaFunction / LuaTable /
LuaRoot Copy values that referenced the released slot
(subsequent reads / calls panic on the stale ticket).
§Threading
Lua inherits Vm’s !Send + !Sync contract. See
docs/threading.md for canonical
embedding patterns.
Structs§
- Lua
mlua-style front door for embedders. Wraps aVmwith JIT installed by default (Vm::new_minimal_with_jit).- LuaFunction
- Handle to a Lua-callable value (
Value::ClosureorValue::Native) pinned in the host root pool.Copy-able — clones share the sameHostRootTicket. - LuaRoot
- Generic pinned root. Use for arbitrary
Values the embedder wants to keep alive without wrapping inLuaFunction/LuaTable. - LuaSandbox
Builder - Sandbox builder that finalizes to a
Lua(instead of a bareVm). - LuaTable
- Handle to a
Value::Tablepinned in the host root pool.
Traits§
- Into
LuaArgs - Convert a tuple of typed values into the
&[Value]shapeVm::call_valueexpects. Implemented for()+ tuples ofIntoValueup to arity 6. - Pinned
Handle - v1.3 Phase SR — common trait for handle types that wrap a
HostRootTicket. LetsLua::unpinacceptLuaFunction/LuaTable/LuaRootuniformly.