lua-rs-derive 0.0.14

Derive macros for the lua-rs embedding API (LuaUserData, lua_methods).
Documentation

Derive macros for the lua-rs embedding API.

  • #[derive(LuaUserData)] on a struct generates the UserData impl that exposes the struct's fields to Lua (obj.field reads/writes), with field attributes #[lua(skip)], #[lua(readonly)], #[lua(name = "...")]. IntoLua comes for free from the runtime's blanket impl<T: UserData> IntoLua for T.
  • Struct attribute #[lua_impl(Display, PartialEq, PartialOrd)] wires the matching metamethods (__tostring, __eq, __lt/__le) from the type's Rust trait impls.
  • Struct attribute #[lua(methods)] makes the generated UserData also register the methods declared by #[lua_methods] on an impl block.
  • #[lua_methods] on an impl block exposes each pub fn(&self/&mut self, ...) to Lua as obj:method(args).