#[derive(LuaUserData)]
{
// Attributes available to this derive:
#[lua]
#[lua_impl]
}
Expand description
Derive UserDataTrait for a struct, exposing public fields to Lua.
§Supported field types (auto-converted to/from UdValue)
i8..i64,isize→UdValue::Integeru8..u64,usize→UdValue::Integerf32,f64→UdValue::Numberbool→UdValue::BooleanString→UdValue::Str
§Field attributes
#[lua(skip)]— exclude from Lua#[lua(readonly)]— get only, no set#[lua(name = "...")]— custom Lua name
§Struct attributes
#[lua_impl(Display, PartialEq, PartialOrd)]— metamethods from Rust traits
§Example
ⓘ
#[derive(LuaUserData, PartialEq, PartialOrd)]
#[lua_impl(Display, PartialEq, PartialOrd)]
struct Point {
pub x: f64,
pub y: f64,
#[lua(skip)]
internal_id: u32,
}