pub type NativeFn = fn(&mut Vm, u32, u32) -> Result<u32, LuaError>;Expand description
Native (host) function: receives the VM, the absolute stack slot of the function value (its own NativeClosure — read upvalues through it), and the argument count; writes results starting at that slot and returns how many.
Embedding contract: prefer Err(LuaError) over panic! for error
signaling. Panics that escape the callback are caught and converted
to a LuaError("native panic: <msg>"), but the VM state may be
inconsistent after a panic (half-pushed args, dangling refs) — the
host should treat any "native panic:"-prefixed error as fatal and
drop the Vm rather than reusing it.