Skip to main content

Crate lua_rs_derive

Crate lua_rs_derive 

Source
Expand description

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).

Attribute Macros§

lua_methods
Expose an impl block’s public methods to Lua as obj:method(args).

Derive Macros§

LuaUserData
Derive UserData for a struct: field access plus optional methods/metamethods.